[FFmpeg-devel] [PATCH] lavf/oggparseopus: Setting seek_preroll in AVCodecContext

Nicolas George george at nsup.org
Wed Feb 5 14:56:31 CET 2014


Le sextidi 16 pluviôse, an CCXXII, Vignesh Venkatasubramanian a écrit :
> Setting seek_preroll value in AVCodecContext for Opus streams
> embedded in ogg container. This is already being done in
> matroskadec. Doing this to achieve consistency so that decoders
> can rely upon this field being populated for opus streams in both
> matroska and ogg containers.

Probably not necessary in the commit message, as you prefer.

> 
> Signed-off-by: Vignesh Venkatasubramanian <vigneshv at google.com>
> ---
>  libavformat/oggparseopus.c | 5 +++++
>  1 file changed, 5 insertions(+)
> 
> diff --git a/libavformat/oggparseopus.c b/libavformat/oggparseopus.c
> index 553ddb0..8dde1e9 100644
> --- a/libavformat/oggparseopus.c
> +++ b/libavformat/oggparseopus.c
> @@ -32,6 +32,7 @@ struct oggopus_private {
>      int64_t cur_dts;
>  };
>  

> +#define OPUS_SEEK_PREROLL 80000000

This is in nanosecods because Matroska uses nanoseconds internally. The Opus
spec expresses it as "80 ms", that is more readable.

>  #define OPUS_HEAD_SIZE 19
>  
>  static int opus_header(AVFormatContext *avf, int idx)
> @@ -66,6 +67,10 @@ static int opus_header(AVFormatContext *avf, int idx)
>          memcpy(st->codec->extradata, packet, os->psize);
>  
>          st->codec->sample_rate = 48000;
> +        av_codec_set_seek_preroll(st->codec,
> +                                  av_rescale_q(OPUS_SEEK_PREROLL,
> +                                               (AVRational){1, 1000000000},
> +                                               (AVRational){1, st->codec->sample_rate}));

av_rescale(OPUS_SEEK_PREROLL, st->codec->sample_rate, 1000);

would be more readable, IMHO.

>          avpriv_set_pts_info(st, 64, 1, 48000);
>          priv->need_comments = 1;
>          return 1;

Looks ok on principle.

Regards,

-- 
  Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20140205/aaabe323/attachment.asc>


More information about the ffmpeg-devel mailing list