From: Michael Niedermayer Date: Sun, 1 Jun 2014 11:35:17 +0000 (+0200) Subject: Merge commit 'eb800f120d2d42590fde2302fe828c847e41e773' X-Git-Tag: n2.3~821 X-Git-Url: http://git.ffmpeg.org/gitweb/ffmpeg.git/commitdiff_plain/0ccfcb0638be99d1fc2c2c1dea6850b3b257ae01 Merge commit 'eb800f120d2d42590fde2302fe828c847e41e773' * commit 'eb800f120d2d42590fde2302fe828c847e41e773': libavcodec: set AVFrame colorspace fields on decoding Conflicts: libavcodec/utils.c See: a80e622924c89df69fb1c225ba432fe12fe6648e Merged-by: Michael Niedermayer --- 0ccfcb0638be99d1fc2c2c1dea6850b3b257ae01 diff --cc libavcodec/utils.c index 641d3c4c67,dff84197c9..e1301b0875 --- a/libavcodec/utils.c +++ b/libavcodec/utils.c @@@ -745,55 -545,99 +745,61 @@@ FF_ENABLE_DEPRECATION_WARNING } } -#if FF_API_GET_BUFFER -FF_DISABLE_DEPRECATION_WARNINGS -int avcodec_default_get_buffer(AVCodecContext *avctx, AVFrame *frame) +int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) { - return avcodec_default_get_buffer2(avctx, frame, 0); -} - -typedef struct CompatReleaseBufPriv { - AVCodecContext avctx; - AVFrame frame; -} CompatReleaseBufPriv; + AVPacket *pkt = avctx->internal->pkt; -static void compat_free_buffer(void *opaque, uint8_t *data) -{ - CompatReleaseBufPriv *priv = opaque; - if (priv->avctx.release_buffer) - priv->avctx.release_buffer(&priv->avctx, &priv->frame); - av_freep(&priv); -} + if (pkt) { + uint8_t *packet_sd; + AVFrameSideData *frame_sd; + int size; + frame->pkt_pts = pkt->pts; + av_frame_set_pkt_pos (frame, pkt->pos); + av_frame_set_pkt_duration(frame, pkt->duration); + av_frame_set_pkt_size (frame, pkt->size); + + /* copy the replaygain data to the output frame */ + packet_sd = av_packet_get_side_data(pkt, AV_PKT_DATA_REPLAYGAIN, &size); + if (packet_sd) { + frame_sd = av_frame_new_side_data(frame, AV_FRAME_DATA_REPLAYGAIN, size); + if (!frame_sd) + return AVERROR(ENOMEM); + + memcpy(frame_sd->data, packet_sd, size); + } -static void compat_release_buffer(void *opaque, uint8_t *data) -{ - AVBufferRef *buf = opaque; - av_buffer_unref(&buf); -} -FF_ENABLE_DEPRECATION_WARNINGS -#endif + /* copy the displaymatrix to the output frame */ + packet_sd = av_packet_get_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX, &size); + if (packet_sd) { + frame_sd = av_frame_new_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX, size); + if (!frame_sd) + return AVERROR(ENOMEM); -int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame) -{ - AVPacket *pkt = avctx->internal->pkt; - uint8_t *packet_sd; - int size; - AVFrameSideData *frame_sd; + memcpy(frame_sd->data, packet_sd, size); + } + } else { + frame->pkt_pts = AV_NOPTS_VALUE; + av_frame_set_pkt_pos (frame, -1); + av_frame_set_pkt_duration(frame, 0); + av_frame_set_pkt_size (frame, -1); + } + frame->reordered_opaque = avctx->reordered_opaque; + #if FF_API_AVFRAME_COLORSPACE + frame->color_primaries = avctx->color_primaries; + frame->color_trc = avctx->color_trc; - frame->colorspace = avctx->colorspace; - frame->color_range = avctx->color_range; ++ if (av_frame_get_colorspace(frame) == AVCOL_SPC_UNSPECIFIED) ++ av_frame_set_colorspace(frame, avctx->colorspace); ++ if (av_frame_get_color_range(frame) == AVCOL_RANGE_UNSPECIFIED) ++ av_frame_set_color_range(frame, avctx->color_range); + frame->chroma_location = avctx->chroma_sample_location; + #endif + - frame->reordered_opaque = avctx->reordered_opaque; - if (!pkt) { - frame->pkt_pts = AV_NOPTS_VALUE; - return 0; - } - - frame->pkt_pts = pkt->pts; - - /* copy the replaygain data to the output frame */ - packet_sd = av_packet_get_side_data(pkt, AV_PKT_DATA_REPLAYGAIN, &size); - if (packet_sd) { - frame_sd = av_frame_new_side_data(frame, AV_FRAME_DATA_REPLAYGAIN, size); - if (!frame_sd) - return AVERROR(ENOMEM); - - memcpy(frame_sd->data, packet_sd, size); - } - /* copy the displaymatrix to the output frame */ - packet_sd = av_packet_get_side_data(pkt, AV_PKT_DATA_DISPLAYMATRIX, &size); - if (packet_sd) { - frame_sd = av_frame_new_side_data(frame, AV_FRAME_DATA_DISPLAYMATRIX, size); - if (!frame_sd) - return AVERROR(ENOMEM); - - memcpy(frame_sd->data, packet_sd, size); - } - - return 0; -} - -int ff_get_buffer(AVCodecContext *avctx, AVFrame *frame, int flags) -{ - const AVHWAccel *hwaccel = avctx->hwaccel; - int override_dimensions = 1; - int ret; - - switch (avctx->codec_type) { + switch (avctx->codec->type) { case AVMEDIA_TYPE_VIDEO: - if (frame->width <= 0 || frame->height <= 0) { - frame->width = FFMAX(avctx->width, avctx->coded_width); - frame->height = FFMAX(avctx->height, avctx->coded_height); - override_dimensions = 0; - } - if (frame->format < 0) - frame->format = avctx->pix_fmt; + frame->format = avctx->pix_fmt; if (!frame->sample_aspect_ratio.num) frame->sample_aspect_ratio = avctx->sample_aspect_ratio; - if (av_frame_get_colorspace(frame) == AVCOL_SPC_UNSPECIFIED) - av_frame_set_colorspace(frame, avctx->colorspace); - if (av_frame_get_color_range(frame) == AVCOL_RANGE_UNSPECIFIED) - av_frame_set_color_range(frame, avctx->color_range); - - if ((ret = av_image_check_size(avctx->width, avctx->height, 0, avctx)) < 0) - return ret; break; case AVMEDIA_TYPE_AUDIO: if (!frame->sample_rate)