On 14/04/14 17:27, Roman Savchenko wrote:
> Ill provide some code samples (it's not purely correct), what i mean:
> 
> static int create_side_data(H264Picture *pic)
> 
> {
> 
>       int i, motion_val_size = 0;
> 
>       AVFrameSideData *mb_type_side_data = NULL;
> 
>       AVFrameSideData *motion_val_side_data = NULL;
> 
> 
>       mb_type_side_data = av_frame_new_side_data(&pic->f,
> AV_FRAME_DATA_MB_TYPE, sizeof(AVBufferRef));
> 
>     if (!mb_type_side_data)
> 
>               goto fail;
> 
> 
>       memcpy(mb_type_side_data->data, pic->mb_type_buf, sizeof(AVBufferRef));
> 
> 
>       motion_val_size = sizeof(pic->motion_val_buf) / 
> sizeof(pic->motion_val_buf[0]);
> 
>       motion_val_side_data = av_frame_new_side_data(&pic->f,
> AV_FRAME_DATA_MOTION_VAL,
> 
>               motion_val_size * sizeof(AVBufferRef));
> 
> 
>       if (!motion_val_side_data)
> 
>               goto fail;
> 
> 
>       for (i = 0; i < motion_val_size; ++i) {
> 
>         AVBufferRef *ref =
> (AVBufferRef*)(&(motion_val_side_data->data[i *
> sizeof(AVBufferRef)]));
> 
>         memcpy(ref, pic->motion_val_buf[i], sizeof(AVBufferRef));
> 
>       }
> 
> 
>       return 0;
> 
> 
> fail:
> 
>       if (mb_type_side_data)
> 
>               av_frame_remove_side_data(&pic->f, AV_FRAME_DATA_MB_TYPE);
> 
>       if (motion_val_side_data)
> 
>               av_frame_remove_side_data(&pic->f, AV_FRAME_DATA_MOTION_VAL);
> 
> 
>       return AVERROR(ENOMEM);
> 
> }
> 
> 
> 
> 
> 2014-04-14 16:29 GMT+03:00 Roman Savchenko <[email protected]>:
> 
>> Hi All,
>>
>> a little bit intro: some times ago I asked at libav-user mailing list
>> about how can I use mb_type and motion_val from H264Picture. They are used
>> in some detection algo that i wrote (its called "Detection in compressed
>> domain"). Luca Barbato answered that it can be a part of side data. But no
>> future discussion are present. And I decided "to patch" by myself.
>>
>> But unfortunately I met a problem, because I don't fully understand
>> architecture idea of some things. And, it'll be very nice, if u'll help me
>> with some advice.

I was waiting either Anton or Vittorio to chip in since they used that
part of Libav the most.

>>
>> For first I add AV_FRAME_DATA_MB_TYPE and AV_FRAME_DATA_MOTION_VAL in
>> AVFrameSideData enum.
>>
>> For second i try to decide what type (or rather copy) in side data  I
>> should use. Because If I'll use AVBufferRef I must (should I?) to ref with
>> av_buffer_ref. But it will provide a allocation for AVBufferRef and
>> AVFrameSideData will provide allocation for AVBufferRef too.  It'll not be
>> a problem if I will copy by value.

Probably would make sense rethinking side data since the amount of
information exported isn't small in this specific case.

>> For third, its pretty the same as second, what type of copy should I use
>> to copy H264Picture.motion_val. If it will be a deep copy should I expand
>> memory to one line or simply provide AV_FRAME_DATA_MOTION_VAL0,
>> AV_FRAME_DATA_MOTION_VAL1?
>>
>> For fourth, and last, can I use expanded_data rather side_data?

Might be interesting in a way but I'm afraid overloading the meaning of
those pointers would be quite annoying.

>> Where should I store knowledge about indexes?

An option would be baking a struct containing all the information and
have a custom destructor to unref properly what's there.


lu
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to