You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-15 14:13:16 +02:00
avcodec/h2645_sei: Factor updating H.2645 SEIs out
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@@ -389,3 +389,32 @@ int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type,
|
|||||||
return FF_H2645_SEI_MESSAGE_UNHANDLED;
|
return FF_H2645_SEI_MESSAGE_UNHANDLED;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src)
|
||||||
|
{
|
||||||
|
int ret = av_buffer_replace(&dst->a53_caption.buf_ref,
|
||||||
|
src->a53_caption.buf_ref);
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < dst->unregistered.nb_buf_ref; i++)
|
||||||
|
av_buffer_unref(&dst->unregistered.buf_ref[i]);
|
||||||
|
dst->unregistered.nb_buf_ref = 0;
|
||||||
|
|
||||||
|
if (src->unregistered.nb_buf_ref) {
|
||||||
|
ret = av_reallocp_array(&dst->unregistered.buf_ref,
|
||||||
|
src->unregistered.nb_buf_ref,
|
||||||
|
sizeof(*dst->unregistered.buf_ref));
|
||||||
|
if (ret < 0)
|
||||||
|
return ret;
|
||||||
|
|
||||||
|
for (unsigned i = 0; i < src->unregistered.nb_buf_ref; i++) {
|
||||||
|
dst->unregistered.buf_ref[i] = av_buffer_ref(src->unregistered.buf_ref[i]);
|
||||||
|
if (!dst->unregistered.buf_ref[i])
|
||||||
|
return AVERROR(ENOMEM);
|
||||||
|
dst->unregistered.nb_buf_ref++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
@@ -130,4 +130,6 @@ int ff_h2645_sei_message_decode(H2645SEI *h, enum SEIType type,
|
|||||||
enum AVCodecID codec_id, GetBitContext *gb,
|
enum AVCodecID codec_id, GetBitContext *gb,
|
||||||
GetByteContext *gbyte, void *logctx);
|
GetByteContext *gbyte, void *logctx);
|
||||||
|
|
||||||
|
int ff_h2645_sei_ctx_replace(H2645SEI *dst, const H2645SEI *src);
|
||||||
|
|
||||||
#endif /* AVCODEC_H2645_SEI_H */
|
#endif /* AVCODEC_H2645_SEI_H */
|
||||||
|
@@ -142,6 +142,12 @@ struct H264ParamSets;
|
|||||||
int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
|
int ff_h264_sei_decode(H264SEIContext *h, GetBitContext *gb,
|
||||||
const struct H264ParamSets *ps, void *logctx);
|
const struct H264ParamSets *ps, void *logctx);
|
||||||
|
|
||||||
|
static inline int ff_h264_sei_ctx_replace(H264SEIContext *dst,
|
||||||
|
const H264SEIContext *src)
|
||||||
|
{
|
||||||
|
return ff_h2645_sei_ctx_replace(&dst->common, &src->common);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset SEI values at the beginning of the frame.
|
* Reset SEI values at the beginning of the frame.
|
||||||
*/
|
*/
|
||||||
|
@@ -434,29 +434,10 @@ int ff_h264_update_thread_context(AVCodecContext *dst,
|
|||||||
|
|
||||||
h->frame_recovered = h1->frame_recovered;
|
h->frame_recovered = h1->frame_recovered;
|
||||||
|
|
||||||
ret = av_buffer_replace(&h->sei.common.a53_caption.buf_ref,
|
ret = ff_h264_sei_ctx_replace(&h->sei, &h1->sei);
|
||||||
h1->sei.common.a53_caption.buf_ref);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (unsigned i = 0; i < h->sei.common.unregistered.nb_buf_ref; i++)
|
|
||||||
av_buffer_unref(&h->sei.common.unregistered.buf_ref[i]);
|
|
||||||
h->sei.common.unregistered.nb_buf_ref = 0;
|
|
||||||
|
|
||||||
if (h1->sei.common.unregistered.nb_buf_ref) {
|
|
||||||
ret = av_reallocp_array(&h->sei.common.unregistered.buf_ref,
|
|
||||||
h1->sei.common.unregistered.nb_buf_ref,
|
|
||||||
sizeof(*h->sei.common.unregistered.buf_ref));
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < h1->sei.common.unregistered.nb_buf_ref; i++) {
|
|
||||||
h->sei.common.unregistered.buf_ref[i] = av_buffer_ref(h1->sei.common.unregistered.buf_ref[i]);
|
|
||||||
if (!h->sei.common.unregistered.buf_ref[i])
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
h->sei.common.unregistered.nb_buf_ref++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
h->sei.common.unregistered.x264_build = h1->sei.common.unregistered.x264_build;
|
h->sei.common.unregistered.x264_build = h1->sei.common.unregistered.x264_build;
|
||||||
|
|
||||||
if (!h->cur_pic_ptr)
|
if (!h->cur_pic_ptr)
|
||||||
|
@@ -107,6 +107,11 @@ struct HEVCParamSets;
|
|||||||
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
|
int ff_hevc_decode_nal_sei(GetBitContext *gb, void *logctx, HEVCSEI *s,
|
||||||
const struct HEVCParamSets *ps, enum HEVCNALUnitType type);
|
const struct HEVCParamSets *ps, enum HEVCNALUnitType type);
|
||||||
|
|
||||||
|
static inline int ff_hevc_sei_ctx_replace(HEVCSEI *dst, const HEVCSEI *src)
|
||||||
|
{
|
||||||
|
return ff_h2645_sei_ctx_replace(&dst->common, &src->common);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset SEI values that are stored on the Context.
|
* Reset SEI values that are stored on the Context.
|
||||||
* e.g. Caption data that was extracted during NAL
|
* e.g. Caption data that was extracted during NAL
|
||||||
|
@@ -3729,30 +3729,10 @@ static int hevc_update_thread_context(AVCodecContext *dst,
|
|||||||
s->max_ra = INT_MAX;
|
s->max_ra = INT_MAX;
|
||||||
}
|
}
|
||||||
|
|
||||||
ret = av_buffer_replace(&s->sei.common.a53_caption.buf_ref,
|
ret = ff_h2645_sei_ctx_replace(&s->sei.common, &s0->sei.common);
|
||||||
s0->sei.common.a53_caption.buf_ref);
|
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
return ret;
|
return ret;
|
||||||
|
|
||||||
for (unsigned i = 0; i < s->sei.common.unregistered.nb_buf_ref; i++)
|
|
||||||
av_buffer_unref(&s->sei.common.unregistered.buf_ref[i]);
|
|
||||||
s->sei.common.unregistered.nb_buf_ref = 0;
|
|
||||||
|
|
||||||
if (s0->sei.common.unregistered.nb_buf_ref) {
|
|
||||||
ret = av_reallocp_array(&s->sei.common.unregistered.buf_ref,
|
|
||||||
s0->sei.common.unregistered.nb_buf_ref,
|
|
||||||
sizeof(*s->sei.common.unregistered.buf_ref));
|
|
||||||
if (ret < 0)
|
|
||||||
return ret;
|
|
||||||
|
|
||||||
for (unsigned i = 0; i < s0->sei.common.unregistered.nb_buf_ref; i++) {
|
|
||||||
s->sei.common.unregistered.buf_ref[i] = av_buffer_ref(s0->sei.common.unregistered.buf_ref[i]);
|
|
||||||
if (!s->sei.common.unregistered.buf_ref[i])
|
|
||||||
return AVERROR(ENOMEM);
|
|
||||||
s->sei.common.unregistered.nb_buf_ref++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ret = av_buffer_replace(&s->sei.common.dynamic_hdr_plus.info,
|
ret = av_buffer_replace(&s->sei.common.dynamic_hdr_plus.info,
|
||||||
s0->sei.common.dynamic_hdr_plus.info);
|
s0->sei.common.dynamic_hdr_plus.info);
|
||||||
if (ret < 0)
|
if (ret < 0)
|
||||||
|
Reference in New Issue
Block a user