Merge commit '87a051f97633010f71dfc1d23d806856499bf231'
authorHendrik Leppkes <h.leppkes@gmail.com>
Sat, 12 Sep 2015 11:30:33 +0000 (13:30 +0200)
committerHendrik Leppkes <h.leppkes@gmail.com>
Sat, 12 Sep 2015 11:30:33 +0000 (13:30 +0200)
* commit '87a051f97633010f71dfc1d23d806856499bf231':
  lavc: allow asynchronous decoders to return correct pkt_dts values

Merged-by: Hendrik Leppkes <h.leppkes@gmail.com>
1  2 
libavcodec/internal.h
libavcodec/mmaldec.c
libavcodec/utils.c

   * all.
   */
  #define FF_CODEC_CAP_INIT_CLEANUP           (1 << 1)
+ /**
+  * Decoders marked with FF_CODEC_CAP_SETS_PKT_DTS want to set
+  * AVFrame.pkt_dts manually. If the flag is set, utils.c won't overwrite
+  * this field. If it's unset, utils.c tries to guess the pkt_dts field
+  * from the input AVPacket.
+  */
+ #define FF_CODEC_CAP_SETS_PKT_DTS           (1 << 2)
  
 -#ifdef DEBUG
 -#   define ff_dlog(ctx, ...) av_log(ctx, AV_LOG_DEBUG, __VA_ARGS__)
 -#else
 -#   define ff_dlog(ctx, ...) while(0)
 -#endif
 -
  #ifdef TRACE
  #   define ff_tlog(ctx, ...) av_log(ctx, AV_LOG_TRACE, __VA_ARGS__)
  #else
Simple merge
@@@ -2080,33 -1476,20 +2080,34 @@@ int attribute_align_arg avcodec_decode_
  
      if ((avctx->codec->capabilities & AV_CODEC_CAP_DELAY) || avpkt->size ||
          (avctx->active_thread_type & FF_THREAD_FRAME)) {
 +        int did_split = av_packet_split_side_data(&tmp);
 +        ret = apply_param_change(avctx, &tmp);
 +        if (ret < 0) {
 +            av_log(avctx, AV_LOG_ERROR, "Error applying parameter changes.\n");
 +            if (avctx->err_recognition & AV_EF_EXPLODE)
 +                goto fail;
 +        }
 +
 +        avctx->internal->pkt = &tmp;
          if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
              ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
 -                                         avpkt);
 +                                         &tmp);
          else {
              ret = avctx->codec->decode(avctx, picture, got_picture_ptr,
 -                                       avpkt);
 +                                       &tmp);
-             picture->pkt_dts = avpkt->dts;
+             if (!(avctx->codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS))
+                 picture->pkt_dts = avpkt->dts;
 +
 +            if(!avctx->has_b_frames){
 +                av_frame_set_pkt_pos(picture, avpkt->pos);
 +            }
 +            //FIXME these should be under if(!avctx->has_b_frames)
              /* get_buffer is supposed to set frame parameters */
              if (!(avctx->codec->capabilities & AV_CODEC_CAP_DR1)) {
 -                picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
 -                picture->width               = avctx->width;
 -                picture->height              = avctx->height;
 -                picture->format              = avctx->pix_fmt;
 +                if (!picture->sample_aspect_ratio.num)    picture->sample_aspect_ratio = avctx->sample_aspect_ratio;
 +                if (!picture->width)                      picture->width               = avctx->width;
 +                if (!picture->height)                     picture->height              = avctx->height;
 +                if (picture->format == AV_PIX_FMT_NONE)   picture->format              = avctx->pix_fmt;
              }
          }