return 0;
}
+static int extract_packet_props(AVCodecInternal *avci, const AVPacket *pkt)
+{
+ av_packet_unref(avci->last_pkt_props);
+ if (pkt)
+ return av_packet_copy_props(avci->last_pkt_props, pkt);
+ return 0;
+}
+
static int unrefcount_frame(AVCodecInternal *avci, AVFrame *frame)
{
int ret;
return AVERROR(ENOSYS);
}
- avctx->internal->pkt = avpkt;
+ ret = extract_packet_props(avci, avpkt);
+ if (ret < 0)
+ return ret;
+
ret = apply_param_change(avctx, avpkt);
if (ret < 0)
return ret;
return AVERROR(ENOSYS);
}
- avctx->internal->pkt = avpkt;
+ ret = extract_packet_props(avci, avpkt);
+ if (ret < 0)
+ return ret;
if (!avpkt->data && avpkt->size) {
av_log(avctx, AV_LOG_ERROR, "invalid packet: NULL data, size != 0\n");
{
int ret;
- avctx->internal->pkt = avpkt;
+ ret = extract_packet_props(avctx->internal, avpkt);
+ if (ret < 0)
+ return ret;
+
*got_sub_ptr = 0;
ret = avctx->codec->decode(avctx, sub, got_sub_ptr, avpkt);
if (*got_sub_ptr)
int ff_decode_frame_props(AVCodecContext *avctx, AVFrame *frame)
{
- AVPacket *pkt = avctx->internal->pkt;
+ AVPacket *pkt = avctx->internal->last_pkt_props;
int i;
struct {
enum AVPacketSideDataType packet;
frame->chroma_location = avctx->chroma_sample_location;
frame->reordered_opaque = avctx->reordered_opaque;
- if (!pkt) {
-#if FF_API_PKT_PTS
-FF_DISABLE_DEPRECATION_WARNINGS
- frame->pkt_pts = AV_NOPTS_VALUE;
-FF_ENABLE_DEPRECATION_WARNINGS
-#endif
- frame->pts = AV_NOPTS_VALUE;
- return 0;
- }
#if FF_API_PKT_PTS
FF_DISABLE_DEPRECATION_WARNINGS
void *thread_ctx;
/**
- * Current packet as passed into the decoder, to avoid having to pass the
- * packet into every function.
+ * Properties (timestamps+side data) extracted from the last packet passed
+ * for decoding.
*/
- AVPacket *pkt;
+ AVPacket *last_pkt_props;
/**
* hwaccel-specific private data
goto free_and_end;
}
+ avctx->internal->last_pkt_props = av_packet_alloc();
+ if (!avctx->internal->last_pkt_props) {
+ ret = AVERROR(ENOMEM);
+ goto free_and_end;
+ }
+
if (codec->priv_data_size > 0) {
if (!avctx->priv_data) {
avctx->priv_data = av_mallocz(codec->priv_data_size);
av_frame_free(&avctx->internal->to_free);
av_frame_free(&avctx->internal->buffer_frame);
av_packet_free(&avctx->internal->buffer_pkt);
+ av_packet_free(&avctx->internal->last_pkt_props);
av_freep(&avctx->internal->pool);
}
av_freep(&avctx->internal);
av_frame_free(&avctx->internal->to_free);
av_frame_free(&avctx->internal->buffer_frame);
av_packet_free(&avctx->internal->buffer_pkt);
+ av_packet_free(&avctx->internal->last_pkt_props);
for (i = 0; i < FF_ARRAY_ELEMS(pool->pools); i++)
av_buffer_pool_uninit(&pool->pools[i]);
av_freep(&avctx->internal->pool);