On Fri, Jun 10, 2016 at 4:56 AM, Anton Khirnov <[email protected]> wrote:
> Quoting Vittorio Giovara (2016-06-10 00:55:18)
>> Store data from each stsd in a separate extradata buffer, keep track of
>> the stsc index for read and seek operations, switch buffers when the
>> index differs. Decoder is notified with an AV_PKT_DATA_NEW_EXTRADATA
>> packet side data.
>>
>> Since H264 supports this notification, and can be reset midstream, enable
>> this feature only for multiple avcC's. All other stsd types (such as
>> hvc1 and hev1) need decoder-side changes, so they are left disabled for
>> now.
>>
>> Signed-off-by: Vittorio Giovara <[email protected]>
>> ---
>> Only modified to avoid caching a zero-sized extradata.
>> Vittorio
>>
>>  libavformat/isom.h |   8 ++++
>>  libavformat/mov.c  | 123 
>> ++++++++++++++++++++++++++++++++++++++++++++++++++---
>>  2 files changed, 125 insertions(+), 6 deletions(-)
>>
>> diff --git a/libavformat/isom.h b/libavformat/isom.h
>> index aec623b..75aa70b 100644
>> --- a/libavformat/isom.h
>> +++ b/libavformat/isom.h
>> @@ -105,6 +105,8 @@ typedef struct MOVStreamContext {
>>      MOVStts *ctts_data;
>>      unsigned int stsc_count;
>>      MOVStsc *stsc_data;
>> +    int stsc_index;
>> +    int stsc_sample;
>>      unsigned int stps_count;
>>      unsigned *stps_data;  ///< partial sync sample for mpeg-2 open gop
>>      int ctts_index;
>> @@ -137,6 +139,12 @@ typedef struct MOVStreamContext {
>>      unsigned int rap_group_count;
>>      MOVSbgp *rap_group;
>>
>> +    /** extradata array (and size) for multiple stsd */
>> +    uint8_t **extradata;
>> +    int *extradata_size;
>> +    int last_stsd_index;
>> +    int stsd_count;
>
> Nit: nb_stsd would be more consistent
>
>> +
>>      int32_t *display_matrix;
>>  } MOVStreamContext;
>>
>> diff --git a/libavformat/mov.c b/libavformat/mov.c
>> index 125919f..9e2d0e2 100644
>> --- a/libavformat/mov.c
>> +++ b/libavformat/mov.c
>> @@ -1771,8 +1771,7 @@ static int mov_skip_multiple_stsd(MOVContext *c, 
>> AVIOContext *pb,
>>      int video_codec_id = ff_codec_get_id(ff_codec_movvideo_tags, format);
>>
>>      if (codec_tag &&
>> -        (codec_tag == AV_RL32("avc1") ||
>> -         codec_tag == AV_RL32("hvc1") ||
>> +        (codec_tag == AV_RL32("hvc1") ||
>>           codec_tag == AV_RL32("hev1") ||
>>           (codec_tag != format &&
>>            (c->fc->video_codec_id ? video_codec_id != c->fc->video_codec_id
>> @@ -1857,6 +1856,20 @@ int ff_mov_read_stsd_entries(MOVContext *c, 
>> AVIOContext *pb, int entries)
>>                  return ret;
>>          } else if (a.size > 0)
>>              avio_skip(pb, a.size);
>> +
>> +        if (sc->stsd_count > 1) {
>
> Are all those checks really necessary? Naively I'd expect that
> stsd_count==1 is not really any different from stsd_count=n for any
> larger n.

I just wanted to avoid needlessly allocating the extra layers and
copying data around.

>> @@ -3376,6 +3434,13 @@ static int mov_read_close(AVFormatContext *s)
>>          av_freep(&sc->stps_data);
>>          av_freep(&sc->rap_group);
>>          av_freep(&sc->display_matrix);
>> +
>> +        if (sc->stsd_count > 1)
>> +            for (j = 0; j < sc->stsd_count; j++)
>> +                if (sc->extradata_size[j] > 0)
>
> This looks rather fragile to me, why not just mallocz sc->extradata and
> then free its elements unconditionally.

ok i'll do that
-- 
Vittorio
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel

Reply via email to