| @@ -57,6 +57,20 @@ · 56 unmodified lines |
| 57 | typedef struct DecodeContext { | 57 | typedef struct DecodeContext { |
| 58 | AVCodecInternal avci; | 58 | AVCodecInternal avci; |
| 59 | | 59 | |
| | 60 | /** |
| | 61 | * This is set to AV_FRAME_FLAG_KEY for decoders of intra-only formats |
| | 62 | * (those whose codec descriptor has AV_CODEC_PROP_INTRA_ONLY set) |
| | 63 | * to set the flag generically. |
| | 64 | */ |
| | 65 | int intra_only_flag; |
| | 66 | |
| | 67 | /** |
| | 68 | * This is set to AV_PICTURE_TYPE_I for intra only video decoders |
| | 69 | * and to AV_PICTURE_TYPE_NONE for other decoders. It is used to set |
| | 70 | * the AVFrame's pict_type before the decoder receives it. |
| | 71 | */ |
| | 72 | enum AVPictureType initial_pict_type; |
| | 73 | |
| 60 | /* to prevent infinite loop on errors when draining */ | 74 | /* to prevent infinite loop on errors when draining */ |
| 61 | int nb_draining_errors; | 75 | int nb_draining_errors; |
| 62 | | 76 | |
| @@ -382,6 +396,7 @@ static int discard_samples(AVCodecContext *avctx, AVFrame *frame, int64_t *disca · 319 unmodified lines |
| 382 | static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples) | 396 | static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, int64_t *discarded_samples) |
| 383 | { | 397 | { |
| 384 | AVCodecInternal *avci = avctx->internal; | 398 | AVCodecInternal *avci = avctx->internal; |
| | 399 | DecodeContext *dc = decode_ctx(avci); |
| 385 | AVPacket *const pkt = avci->in_pkt; | 400 | AVPacket *const pkt = avci->in_pkt; |
| 386 | const FFCodec *const codec = ffcodec(avctx->codec); | 401 | const FFCodec *const codec = ffcodec(avctx->codec); |
| 387 | int got_frame, consumed; | 402 | int got_frame, consumed; |
| @@ -409,6 +424,8 @@ static inline int decode_simple_internal(AVCodecContext *avctx, AVFrame *frame, · 21 unmodified lines |
| 409 | if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) { | 424 | if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) { |
| 410 | consumed = ff_thread_decode_frame(avctx, frame, &got_frame, pkt); | 425 | consumed = ff_thread_decode_frame(avctx, frame, &got_frame, pkt); |
| 411 | } else { | 426 | } else { |
| | 427 | frame->pict_type = dc->initial_pict_type; |
| | 428 | frame->flags |= dc->intra_only_flag; |
| 412 | consumed = codec->cb.decode(avctx, frame, &got_frame, pkt); | 429 | consumed = codec->cb.decode(avctx, frame, &got_frame, pkt); |
| 413 | | 430 | |
| 414 | if (!(codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS)) | 431 | if (!(codec->caps_internal & FF_CODEC_CAP_SETS_PKT_DTS)) |
| @@ -598,6 +615,8 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) · 183 unmodified lines |
| 598 | av_assert0(!frame->buf[0]); | 615 | av_assert0(!frame->buf[0]); |
| 599 | | 616 | |
| 600 | if (codec->cb_type == FF_CODEC_CB_TYPE_RECEIVE_FRAME) { | 617 | if (codec->cb_type == FF_CODEC_CB_TYPE_RECEIVE_FRAME) { |
| | 618 | frame->pict_type = dc->initial_pict_type; |
| | 619 | frame->flags |= dc->intra_only_flag; |
| 601 | ret = codec->cb.receive_frame(avctx, frame); | 620 | ret = codec->cb.receive_frame(avctx, frame); |
| 602 | emms_c(); | 621 | emms_c(); |
| 603 | if (!ret) { | 622 | if (!ret) { |
| @@ -627,8 +646,7 @@ static int decode_receive_frame_internal(AVCodecContext *avctx, AVFrame *frame) · 23 unmodified lines |
| 627 | frame->width = avctx->width; | 646 | frame->width = avctx->width; |
| 628 | if (!frame->height) | 647 | if (!frame->height) |
| 629 | frame->height = avctx->height; | 648 | frame->height = avctx->height; |
| 630 | } else | 649 | } |
| 631 | frame->flags |= AV_FRAME_FLAG_KEY; | | |
| 632 | | 650 | |
| 633 | ret = fill_frame_props(avctx, frame); | 651 | ret = fill_frame_props(avctx, frame); |
| 634 | if (ret < 0) { | 652 | if (ret < 0) { |
| @@ -1794,6 +1812,13 @@ int ff_decode_preinit(AVCodecContext *avctx) · 1159 unmodified lines |
| 1794 | DecodeContext *dc = decode_ctx(avci); | 1812 | DecodeContext *dc = decode_ctx(avci); |
| 1795 | int ret = 0; | 1813 | int ret = 0; |
| 1796 | | 1814 | |
| | 1815 | dc->initial_pict_type = AV_PICTURE_TYPE_NONE; |
| | 1816 | if (avctx->codec_descriptor->props & AV_CODEC_PROP_INTRA_ONLY) { |
| | 1817 | dc->intra_only_flag = AV_FRAME_FLAG_KEY; |
| | 1818 | if (avctx->codec_type == AVMEDIA_TYPE_VIDEO) |
| | 1819 | dc->initial_pict_type = AV_PICTURE_TYPE_I; |
| | 1820 | } |
| | 1821 | |
| 1797 | /* if the decoder init function was already called previously, | 1822 | /* if the decoder init function was already called previously, |
| 1798 | * free the already allocated subtitle_header before overwriting it */ | 1823 | * free the already allocated subtitle_header before overwriting it */ |
| 1799 | av_freep(&avctx->subtitle_header); | 1824 | av_freep(&avctx->subtitle_header); |