summaryrefslogtreecommitdiffstats
path: root/libavcodec/mpeg2_metadata_bsf.c
diff options
context:
space:
mode:
authorAndreas Rheinhardt <andreas.rheinhardt@gmail.com>2019-06-20 01:45:08 +0200
committerMark Thompson <sw@jkqxz.net>2019-07-07 23:04:27 +0100
commit42114094da35264c2b6710efa3772b2d5de6ba46 (patch)
treebcb1da736b179db3415993a4ae2d3cef822f4203 /libavcodec/mpeg2_metadata_bsf.c
parentdd5ce54d2a44ecb8be6c3bb9396839a8d8fb1742 (diff)
downloadffmpeg-streaming-42114094da35264c2b6710efa3772b2d5de6ba46.zip
ffmpeg-streaming-42114094da35264c2b6710efa3772b2d5de6ba46.tar.gz
mpeg2_metadata: Localize inserting of sequence display extensions
If a new sequence display extension had to be added, this was up until now done at two places: One where a sequence display extension was initialized with default values and one where the actual sequence display extension was inserted into the fragment. This division of labour is unnecessary and pointless; it has been changed. Furthermore, if a sequence display extension has to be added, the earlier code set some fields to their default value twice. This has been changed, too. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@gmail.com>
Diffstat (limited to 'libavcodec/mpeg2_metadata_bsf.c')
-rw-r--r--libavcodec/mpeg2_metadata_bsf.c34
1 files changed, 12 insertions, 22 deletions
diff --git a/libavcodec/mpeg2_metadata_bsf.c b/libavcodec/mpeg2_metadata_bsf.c
index 082137d..6779ffd 100644
--- a/libavcodec/mpeg2_metadata_bsf.c
+++ b/libavcodec/mpeg2_metadata_bsf.c
@@ -53,7 +53,7 @@ static int mpeg2_metadata_update_fragment(AVBSFContext *bsf,
MPEG2RawSequenceHeader *sh = NULL;
MPEG2RawSequenceExtension *se = NULL;
MPEG2RawSequenceDisplayExtension *sde = NULL;
- int i, se_pos, add_sde = 0;
+ int i, se_pos;
for (i = 0; i < frag->nb_units; i++) {
if (frag->units[i].type == MPEG2_START_SEQUENCE_HEADER) {
@@ -115,7 +115,7 @@ static int mpeg2_metadata_update_fragment(AVBSFContext *bsf,
ctx->transfer_characteristics >= 0 ||
ctx->matrix_coefficients >= 0) {
if (!sde) {
- add_sde = 1;
+ int err;
ctx->sequence_display_extension.extension_start_code =
MPEG2_START_EXTENSION;
ctx->sequence_display_extension.extension_start_code_identifier =
@@ -135,6 +135,16 @@ static int mpeg2_metadata_update_fragment(AVBSFContext *bsf,
.display_vertical_size =
se->vertical_size_extension << 12 | sh->vertical_size_value,
};
+
+ err = ff_cbs_insert_unit_content(ctx->cbc, frag, se_pos + 1,
+ MPEG2_START_EXTENSION,
+ &ctx->sequence_display_extension,
+ NULL);
+ if (err < 0) {
+ av_log(bsf, AV_LOG_ERROR, "Failed to insert new sequence "
+ "display extension.\n");
+ return err;
+ }
}
if (ctx->video_format >= 0)
@@ -147,32 +157,12 @@ static int mpeg2_metadata_update_fragment(AVBSFContext *bsf,
if (ctx->colour_primaries >= 0)
sde->colour_primaries = ctx->colour_primaries;
- else if (add_sde)
- sde->colour_primaries = 2;
if (ctx->transfer_characteristics >= 0)
sde->transfer_characteristics = ctx->transfer_characteristics;
- else if (add_sde)
- sde->transfer_characteristics = 2;
if (ctx->matrix_coefficients >= 0)
sde->matrix_coefficients = ctx->matrix_coefficients;
- else if (add_sde)
- sde->matrix_coefficients = 2;
- }
- }
-
- if (add_sde) {
- int err;
-
- err = ff_cbs_insert_unit_content(ctx->cbc, frag, se_pos + 1,
- MPEG2_START_EXTENSION,
- &ctx->sequence_display_extension,
- NULL);
- if (err < 0) {
- av_log(bsf, AV_LOG_ERROR, "Failed to insert new sequence "
- "display extension.\n");
- return err;
}
}
OpenPOWER on IntegriCloud