[FFmpeg-devel] [PATCH] matroska: Set CodecDelay and SeekPreroll in the AVStream
Vignesh Venkatasubramanian
vigneshv at google.com
Tue Sep 24 19:35:47 CEST 2013
On Tue, Sep 24, 2013 at 3:53 AM, Michael Niedermayer <michaelni at gmx.at> wrote:
> On Mon, Sep 23, 2013 at 04:03:25PM -0700, Vignesh Venkatasubramanian wrote:
>> On Mon, Sep 23, 2013 at 4:02 PM, Vignesh Venkatasubramanian
>> <vigneshv at google.com> wrote:
>> > This patch exports the values of Codec Delay and Seek Preroll
>> > container elements as in the AVStream structure. The seek_preroll
>> > field has been added to the AVStream struct and the minor version
>> > of libavformat has been bumped.
>> >
>> > Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
>> > ---
>> > libavformat/avformat.h | 16 ++++++++++++++++
>> > libavformat/matroskadec.c | 14 ++++++++++++++
>> > libavformat/version.h | 2 +-
>> > 3 files changed, 31 insertions(+), 1 deletion(-)
>> >
>> > diff --git a/libavformat/avformat.h b/libavformat/avformat.h
>> > index b18eb3f..6671a83 100644
>> > --- a/libavformat/avformat.h
>> > +++ b/libavformat/avformat.h
>> > @@ -856,6 +856,9 @@ typedef struct AVStream {
>> >
>> > /**
>> > * Number of samples to skip at the start of the frame decoded from the next packet.
>> > + *
>> > + * Code outside avformat should access this field using:
>> > + * av_stream_get_skip_samples/set_skip_samples(stream)
>> > */
>> > int skip_samples;
>
> when does code outside lavf need to access this ?
>
you are right. it need not be accessed outside lavf.
>
>> >
>> > @@ -888,10 +891,23 @@ typedef struct AVStream {
>> > */
>> > int pts_wrap_behavior;
>> >
>> > + /**
>> > + * Number of samples to skip after a discontinuity. For example, when a seek
>> > + * happens.
>> > + *
>> > + * Code outside avformat should access this field using:
>> > + * av_stream_get/set_seek_preroll(stream)
>> > + */
>> > + int seek_preroll;
>> > +
>> > } AVStream;
>> >
>> > AVRational av_stream_get_r_frame_rate(const AVStream *s);
>> > void av_stream_set_r_frame_rate(AVStream *s, AVRational r);
>> > +int av_stream_get_skip_samples(const AVStream *s);
>> > +void av_stream_set_skip_samples(AVStream *s, int skip_samples);
>> > +int av_stream_get_seek_preroll(const AVStream *s);
>> > +void av_stream_set_seek_preroll(AVStream *s, int seek_preroll);
>> >
>> > #define AV_PROGRAM_RUNNING 1
>> >
>> > diff --git a/libavformat/matroskadec.c b/libavformat/matroskadec.c
>> > index a1b7f56..ecbc723 100644
>> > --- a/libavformat/matroskadec.c
>> > +++ b/libavformat/matroskadec.c
>> > @@ -163,6 +163,8 @@ typedef struct {
>> > uint64_t default_duration;
>> > uint64_t flag_default;
>> > uint64_t flag_forced;
>> > + uint64_t codec_delay;
>> > + uint64_t seek_preroll;
>> > MatroskaTrackVideo video;
>> > MatroskaTrackAudio audio;
>> > MatroskaTrackOperation operation;
>> > @@ -410,6 +412,8 @@ static EbmlSyntax matroska_track[] = {
>> > { MATROSKA_ID_TRACKOPERATION, EBML_NEST, 0, offsetof(MatroskaTrack,operation), {.n=matroska_track_operation} },
>> > { MATROSKA_ID_TRACKCONTENTENCODINGS,EBML_NEST, 0, 0, {.n=matroska_track_encodings} },
>> > { MATROSKA_ID_TRACKMAXBLKADDID, EBML_UINT, 0, offsetof(MatroskaTrack,max_block_additional_id) },
>> > + { MATROSKA_ID_CODECDELAY, EBML_UINT, 0, offsetof(MatroskaTrack,codec_delay) },
>> > + { MATROSKA_ID_SEEKPREROLL, EBML_UINT, 0, offsetof(MatroskaTrack,seek_preroll) },
>> > { MATROSKA_ID_TRACKFLAGENABLED, EBML_NONE },
>> > { MATROSKA_ID_TRACKFLAGLACING, EBML_NONE },
>> > { MATROSKA_ID_CODECNAME, EBML_NONE },
>
>> > @@ -1874,6 +1878,16 @@ static int matroska_read_header(AVFormatContext *s)
>> > st->codec->bits_per_coded_sample = track->audio.bitdepth;
>> > if (st->codec->codec_id != AV_CODEC_ID_AAC)
>> > st->need_parsing = AVSTREAM_PARSE_HEADERS;
>> > + if (track->codec_delay > 0) {
>> > + st->skip_samples = av_rescale_q(track->codec_delay,
>> > + (AVRational){1, 1000000000},
>> > + (AVRational){1, st->codec->sample_rate});
>> > + }
>
> i suspect this alone wont work when the user seeks back to the first
> packet
i don't understand why. can you please explain?
> also the addition of seek_preroll to the core and changing
> skip_samples in matroskadec could be in seperate patches (would also
> simplify future debugability with bisect)
have uploaded smaller patches, please abandon this thread (not sure if this
is the right way to do this - how do i reply to the same thread when the commit
message changes? git send-email doesn't seem to respect --in-reply-to when the
commit message changes. Just asking so that i don't do the same mistake in the
future (assuming it's not the right way)).
>
>
>> > + if (track->seek_preroll > 0) {
>> > + st->seek_preroll = av_rescale_q(track->seek_preroll,
>> > + (AVRational){1, 1000000000},
>> > + (AVRational){1, st->codec->sample_rate});
>> > + }
>> > } else if (codec_id == AV_CODEC_ID_WEBVTT) {
>> > st->codec->codec_type = AVMEDIA_TYPE_SUBTITLE;
>> >
>> > diff --git a/libavformat/version.h b/libavformat/version.h
>> > index c224232..ff38e96 100644
>> > --- a/libavformat/version.h
>> > +++ b/libavformat/version.h
>> > @@ -30,7 +30,7 @@
>> > #include "libavutil/avutil.h"
>> >
>> > #define LIBAVFORMAT_VERSION_MAJOR 55
>> > -#define LIBAVFORMAT_VERSION_MINOR 18
>> > +#define LIBAVFORMAT_VERSION_MINOR 19
>> > #define LIBAVFORMAT_VERSION_MICRO 102
>>
>> I am unsure if i should reset the micro version while bumping the
>> minor version. Looking at
>> older patches suggests that i shouldn't. Please let me know if i'm
>> wrong. Thanks.
>
> micro should be reset to 100 when minor or major is bumped
>
Done, thanks.
> [...]
>
> --
> Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
>
> Into a blind darkness they enter who follow after the Ignorance,
> they as if into a greater darkness enter who devote themselves
> to the Knowledge alone. -- Isha Upanishad
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel at ffmpeg.org
> http://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
More information about the ffmpeg-devel
mailing list