[FFmpeg-devel] [PATCH] Pass pts values through non-delay encoders by default.

Michael Niedermayer michaelni at gmx.at
Mon Jan 23 04:46:45 CET 2012

On Sun, Jan 22, 2012 at 02:39:52PM +0100, Reimar Döffinger wrote:
> Avoids having to duplicate the code for trivial, non-reordering
> encoders.
> Completely and utterly breaks almost all H.264 conformance tests,
> sometimes just making the pts start with negative values, sometimes
> only giving 2 instead of 20 decoded frames or failing with not
> correctly ordered pts.
> Signed-off-by: Reimar Döffinger <Reimar.Doeffinger at gmx.de>
> ---
>  libavcodec/utils.c |    6 ++++++
>  1 files changed, 6 insertions(+), 0 deletions(-)
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index a505fa5..25ad3eb 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -1145,6 +1145,12 @@ int attribute_align_arg avcodec_encode_video(AVCodecContext *avctx, uint8_t *buf
>          int ret = avctx->codec->encode(avctx, buf, buf_size, pict);
>          avctx->frame_number++;
>          emms_c(); //needed to avoid an emms_c() call before every return;
> +        if (!(avctx->codec->capabilities & CODEC_CAP_DELAY)) {
> +            if (!avctx->coded_frame)
> +                avctx->coded_frame = pict;

coded_frame is supposed to be managed by the encoder, setting it from
outside doesnt feel safe. (a failing malloc and its NULL and a free
later and theres a double free just as one example)
also theres a problem with the lifetime of the objects
coded_frame should be valid till the next avcodec* call at least
but the pict argument might become invalid sooner than that.

its not as generic but i would suggest to move this logic into
or at least limit the hacking to ->pts

also it would be interresting to check that no codec that does
currently output something changes with this modification

Michael     GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB

The bravest are surely those who have the clearest vision
of what is before them, glory and danger alike, and yet
notwithstanding go out to meet it. -- Thucydides
-------------- next part --------------
A non-text attachment was scrubbed...
Name: not available
Type: application/pgp-signature
Size: 198 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20120123/981f90de/attachment.asc>

More information about the ffmpeg-devel mailing list