Commit ab71be09 authored by Michael Niedermayer's avatar Michael Niedermayer

Merge commit 'da6506c6'

* commit 'da6506c6':
  lavc: move AVCodecContext.pkt to AVCodecInternal

Conflicts:
	libavcodec/internal.h
	libavcodec/rawdec.c
	libavcodec/utils.c
Merged-by: 's avatarMichael Niedermayer <michaelni@gmx.at>
parents 3fc26d80 da6506c6
...@@ -2821,14 +2821,13 @@ typedef struct AVCodecContext { ...@@ -2821,14 +2821,13 @@ typedef struct AVCodecContext {
*/ */
int error_rate; int error_rate;
#if FF_API_CODEC_PKT
/** /**
* Current packet as passed into the decoder, to avoid having * @deprecated this field is not supposed to be accessed from outside lavc
* to pass the packet into every function. Currently only valid
* inside lavc and get/release_buffer callbacks.
* - decoding: set by avcodec_decode_*, read by get_buffer() for setting pkt_pts
* - encoding: unused
*/ */
attribute_deprecated
AVPacket *pkt; AVPacket *pkt;
#endif
/** /**
* VBV delay coded in the last frame (in periods of a 27 MHz clock). * VBV delay coded in the last frame (in periods of a 27 MHz clock).
......
...@@ -915,8 +915,8 @@ static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *a ...@@ -915,8 +915,8 @@ static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *a
H264Context *h = priv->parser->priv_data; H264Context *h = priv->parser->priv_data;
index = av_parser_parse2(priv->parser, avctx, &pout, &psize, index = av_parser_parse2(priv->parser, avctx, &pout, &psize,
in_data, len, avctx->pkt->pts, in_data, len, avctx->internal->pkt->pts,
avctx->pkt->dts, 0); avctx->internal->pkt->dts, 0);
if (index < 0) { if (index < 0) {
av_log(avctx, AV_LOG_WARNING, av_log(avctx, AV_LOG_WARNING,
"CrystalHD: Failed to parse h.264 packet to " "CrystalHD: Failed to parse h.264 packet to "
...@@ -950,7 +950,7 @@ static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *a ...@@ -950,7 +950,7 @@ static int decode(AVCodecContext *avctx, void *data, int *got_frame, AVPacket *a
* avoiding mangling so we need to build a mapping to values * avoiding mangling so we need to build a mapping to values
* we know will not be mangled. * we know will not be mangled.
*/ */
uint64_t pts = opaque_list_push(priv, avctx->pkt->pts, pic_type); uint64_t pts = opaque_list_push(priv, avctx->internal->pkt->pts, pic_type);
if (!pts) { if (!pts) {
if (free_data) { if (free_data) {
av_freep(&in_data); av_freep(&in_data);
......
...@@ -97,6 +97,12 @@ typedef struct AVCodecInternal { ...@@ -97,6 +97,12 @@ typedef struct AVCodecInternal {
void *thread_ctx; void *thread_ctx;
/**
* Current packet as passed into the decoder, to avoid having to pass the
* packet into every function.
*/
AVPacket *pkt;
/** /**
* temporary buffer used for encoders to store their bitstream * temporary buffer used for encoders to store their bitstream
*/ */
......
...@@ -656,7 +656,6 @@ int ff_frame_thread_init(AVCodecContext *avctx) ...@@ -656,7 +656,6 @@ int ff_frame_thread_init(AVCodecContext *avctx)
} }
*copy = *src; *copy = *src;
copy->pkt = &p->avpkt;
copy->internal = av_malloc(sizeof(AVCodecInternal)); copy->internal = av_malloc(sizeof(AVCodecInternal));
if (!copy->internal) { if (!copy->internal) {
...@@ -665,6 +664,7 @@ int ff_frame_thread_init(AVCodecContext *avctx) ...@@ -665,6 +664,7 @@ int ff_frame_thread_init(AVCodecContext *avctx)
} }
*copy->internal = *src->internal; *copy->internal = *src->internal;
copy->internal->thread_ctx = p; copy->internal->thread_ctx = p;
copy->internal->pkt = &p->avpkt;
if (!i) { if (!i) {
src = copy; src = copy;
......
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
*/ */
#include "avcodec.h" #include "avcodec.h"
#include "internal.h"
#include "raw.h" #include "raw.h"
#include "libavutil/avassert.h" #include "libavutil/avassert.h"
#include "libavutil/buffer.h" #include "libavutil/buffer.h"
...@@ -182,9 +183,9 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame, ...@@ -182,9 +183,9 @@ static int raw_decode(AVCodecContext *avctx, void *data, int *got_frame,
frame->pict_type = AV_PICTURE_TYPE_I; frame->pict_type = AV_PICTURE_TYPE_I;
frame->key_frame = 1; frame->key_frame = 1;
frame->reordered_opaque = avctx->reordered_opaque; frame->reordered_opaque = avctx->reordered_opaque;
frame->pkt_pts = avctx->pkt->pts; frame->pkt_pts = avctx->internal->pkt->pts;
av_frame_set_pkt_pos (frame, avctx->pkt->pos); av_frame_set_pkt_pos (frame, avctx->internal->pkt->pos);
av_frame_set_pkt_duration(frame, avctx->pkt->duration); av_frame_set_pkt_duration(frame, avctx->internal->pkt->duration);
if (context->tff >= 0) { if (context->tff >= 0) {
frame->interlaced_frame = 1; frame->interlaced_frame = 1;
......
...@@ -729,11 +729,11 @@ FF_ENABLE_DEPRECATION_WARNINGS ...@@ -729,11 +729,11 @@ FF_ENABLE_DEPRECATION_WARNINGS
int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame) int ff_init_buffer_info(AVCodecContext *avctx, AVFrame *frame)
{ {
if (avctx->pkt) { if (avctx->internal->pkt) {
frame->pkt_pts = avctx->pkt->pts; frame->pkt_pts = avctx->internal->pkt->pts;
av_frame_set_pkt_pos (frame, avctx->pkt->pos); av_frame_set_pkt_pos (frame, avctx->internal->pkt->pos);
av_frame_set_pkt_duration(frame, avctx->pkt->duration); av_frame_set_pkt_duration(frame, avctx->internal->pkt->duration);
av_frame_set_pkt_size (frame, avctx->pkt->size); av_frame_set_pkt_size (frame, avctx->internal->pkt->size);
} else { } else {
frame->pkt_pts = AV_NOPTS_VALUE; frame->pkt_pts = AV_NOPTS_VALUE;
av_frame_set_pkt_pos (frame, -1); av_frame_set_pkt_pos (frame, -1);
...@@ -2026,7 +2026,7 @@ static int add_metadata_from_side_data(AVCodecContext *avctx, AVFrame *frame) ...@@ -2026,7 +2026,7 @@ static int add_metadata_from_side_data(AVCodecContext *avctx, AVFrame *frame)
const uint8_t *side_metadata; const uint8_t *side_metadata;
const uint8_t *end; const uint8_t *end;
side_metadata = av_packet_get_side_data(avctx->pkt, side_metadata = av_packet_get_side_data(avctx->internal->pkt,
AV_PKT_DATA_STRINGS_METADATA, &size); AV_PKT_DATA_STRINGS_METADATA, &size);
if (!side_metadata) if (!side_metadata)
goto end; goto end;
...@@ -2084,7 +2084,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi ...@@ -2084,7 +2084,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
goto fail; goto fail;
} }
avctx->pkt = &tmp; avctx->internal->pkt = &tmp;
if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr, ret = ff_thread_decode_frame(avctx, picture, got_picture_ptr,
&tmp); &tmp);
...@@ -2110,7 +2110,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi ...@@ -2110,7 +2110,7 @@ int attribute_align_arg avcodec_decode_video2(AVCodecContext *avctx, AVFrame *pi
fail: fail:
emms_c(); //needed to avoid an emms_c() call before every return; emms_c(); //needed to avoid an emms_c() call before every return;
avctx->pkt = NULL; avctx->internal->pkt = NULL;
if (did_split) { if (did_split) {
av_packet_free_side_data(&tmp); av_packet_free_side_data(&tmp);
if(ret == tmp.size) if(ret == tmp.size)
...@@ -2233,7 +2233,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, ...@@ -2233,7 +2233,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
goto fail; goto fail;
} }
avctx->pkt = &tmp; avctx->internal->pkt = &tmp;
if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME) if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
ret = ff_thread_decode_frame(avctx, frame, got_frame_ptr, &tmp); ret = ff_thread_decode_frame(avctx, frame, got_frame_ptr, &tmp);
else { else {
...@@ -2257,7 +2257,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, ...@@ -2257,7 +2257,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
frame->sample_rate = avctx->sample_rate; frame->sample_rate = avctx->sample_rate;
} }
side= av_packet_get_side_data(avctx->pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size); side= av_packet_get_side_data(avctx->internal->pkt, AV_PKT_DATA_SKIP_SAMPLES, &side_size);
if(side && side_size>=10) { if(side && side_size>=10) {
avctx->internal->skip_samples = AV_RL32(side); avctx->internal->skip_samples = AV_RL32(side);
av_log(avctx, AV_LOG_DEBUG, "skip %d samples due to side data\n", av_log(avctx, AV_LOG_DEBUG, "skip %d samples due to side data\n",
...@@ -2312,7 +2312,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx, ...@@ -2312,7 +2312,7 @@ int attribute_align_arg avcodec_decode_audio4(AVCodecContext *avctx,
} }
} }
fail: fail:
avctx->pkt = NULL; avctx->internal->pkt = NULL;
if (did_split) { if (did_split) {
av_packet_free_side_data(&tmp); av_packet_free_side_data(&tmp);
if(ret == tmp.size) if(ret == tmp.size)
...@@ -2454,7 +2454,7 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, ...@@ -2454,7 +2454,7 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
if (ret < 0) { if (ret < 0) {
*got_sub_ptr = 0; *got_sub_ptr = 0;
} else { } else {
avctx->pkt = &pkt_recoded; avctx->internal->pkt = &pkt_recoded;
if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE) if (avctx->pkt_timebase.den && avpkt->pts != AV_NOPTS_VALUE)
sub->pts = av_rescale_q(avpkt->pts, sub->pts = av_rescale_q(avpkt->pts,
...@@ -2491,7 +2491,7 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub, ...@@ -2491,7 +2491,7 @@ int avcodec_decode_subtitle2(AVCodecContext *avctx, AVSubtitle *sub,
sub->format = 0; sub->format = 0;
else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB) else if (avctx->codec_descriptor->props & AV_CODEC_PROP_TEXT_SUB)
sub->format = 1; sub->format = 1;
avctx->pkt = NULL; avctx->internal->pkt = NULL;
} }
if (did_split) { if (did_split) {
......
...@@ -111,5 +111,8 @@ ...@@ -111,5 +111,8 @@
#ifndef FF_API_THREAD_OPAQUE #ifndef FF_API_THREAD_OPAQUE
#define FF_API_THREAD_OPAQUE (LIBAVCODEC_VERSION_MAJOR < 56) #define FF_API_THREAD_OPAQUE (LIBAVCODEC_VERSION_MAJOR < 56)
#endif #endif
#ifndef FF_API_CODEC_PKT
#define FF_API_CODEC_PKT (LIBAVCODEC_VERSION_MAJOR < 56)
#endif
#endif /* AVCODEC_VERSION_H */ #endif /* AVCODEC_VERSION_H */
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment