* [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it
@ 2024-03-27 1:36 Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 2/6] avcodec/libvpxenc: Remove obsolete av_unused Andreas Rheinhardt
` (5 more replies)
0 siblings, 6 replies; 9+ messages in thread
From: Andreas Rheinhardt @ 2024-03-27 1:36 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Also rewrite the code so that a variable that is only used
depending upon CONFIG_LIBVPX_VP9_ENCODER is not declared
outside of the #if block.
(The variable was declared with av_uninit, but it should have been
av_unused, as the former does not work for all compilers.)
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/libvpxenc.c | 19 ++++++++++---------
1 file changed, 10 insertions(+), 9 deletions(-)
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 4b89e47e83..ee903a4e5c 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -357,19 +357,20 @@ static int frame_data_submit(AVCodecContext *avctx, AVFifo *fifo,
const struct vpx_codec_enc_cfg *enccfg = ctx->encoder.config.enc;
FrameData fd = { .pts = frame->pts };
-
- AVFrameSideData *av_uninit(sd);
int ret;
#if CONFIG_LIBVPX_VP9_ENCODER
- // Keep HDR10+ if it has bit depth higher than 8 and
- // it has PQ trc (SMPTE2084).
- sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
- if (avctx->codec_id == AV_CODEC_ID_VP9 && sd &&
+ if (avctx->codec_id == AV_CODEC_ID_VP9 &&
+ // Keep HDR10+ if it has bit depth higher than 8 and
+ // it has PQ trc (SMPTE2084).
enccfg->g_bit_depth > 8 && avctx->color_trc == AVCOL_TRC_SMPTE2084) {
- fd.hdr10_plus = av_buffer_ref(sd->buf);
- if (!fd.hdr10_plus)
- return AVERROR(ENOMEM);
+ const AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
+
+ if (sd) {
+ fd.hdr10_plus = av_buffer_ref(sd->buf);
+ if (!fd.hdr10_plus)
+ return AVERROR(ENOMEM);
+ }
}
#endif
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 2/6] avcodec/libvpxenc: Remove obsolete av_unused
2024-03-27 1:36 [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it Andreas Rheinhardt
@ 2024-03-27 1:38 ` Andreas Rheinhardt
2024-03-27 17:30 ` James Zern via ffmpeg-devel
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 3/6] avcodec/h264_refs: Rewrite code to make control flow clearer Andreas Rheinhardt
` (4 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Andreas Rheinhardt @ 2024-03-27 1:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Forgotten in 753074721bd414874d18c372c491bdc6323fa3bf.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/libvpxenc.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
index 42f73a92f6..f7bfdc1461 100644
--- a/libavcodec/libvpxenc.c
+++ b/libavcodec/libvpxenc.c
@@ -786,7 +786,7 @@ static int set_pix_fmt(AVCodecContext *avctx, vpx_codec_caps_t codec_caps,
struct vpx_codec_enc_cfg *enccfg, vpx_codec_flags_t *flags,
vpx_img_fmt_t *img_fmt)
{
- VPxContext av_unused *ctx = avctx->priv_data;
+ VPxContext *ctx = avctx->priv_data;
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(avctx->pix_fmt);
enccfg->g_bit_depth = enccfg->g_input_bit_depth = desc->comp[0].depth;
switch (avctx->pix_fmt) {
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 3/6] avcodec/h264_refs: Rewrite code to make control flow clearer
2024-03-27 1:36 [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 2/6] avcodec/libvpxenc: Remove obsolete av_unused Andreas Rheinhardt
@ 2024-03-27 1:38 ` Andreas Rheinhardt
2024-03-29 20:25 ` Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 4/6] avcodec/h264_refs: Use smaller scope, don't use av_uninit Andreas Rheinhardt
` (3 subsequent siblings)
5 siblings, 1 reply; 9+ messages in thread
From: Andreas Rheinhardt @ 2024-03-27 1:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
While this change IMO makes the control flow clearer
for the human reader, it is especially important for
GCC: It erroneously believes that it is possible to
enter the SHORT2(UNUSED|LONG) cases without having
entered the preceding block that initializes pic,
frame_num, structure and j; it would emit -Wmaybe-uninitialized
warnings for these variables if they were not pseudo-
initialized with av_uninit(). This patch allows to remove
the latter.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h264_refs.c | 22 ++++++++++------------
1 file changed, 10 insertions(+), 12 deletions(-)
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index 9bc7b20988..c2ba4b9b9e 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -646,8 +646,9 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
av_log(h->avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode,
h->mmco[i].short_pic_num, h->mmco[i].long_arg);
- if (mmco[i].opcode == MMCO_SHORT2UNUSED ||
- mmco[i].opcode == MMCO_SHORT2LONG) {
+ switch (mmco[i].opcode) {
+ case MMCO_SHORT2UNUSED:
+ case MMCO_SHORT2LONG:
frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure);
pic = find_short(h, frame_num, &j);
if (!pic) {
@@ -659,16 +660,12 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
}
continue;
}
- }
-
- switch (mmco[i].opcode) {
- case MMCO_SHORT2UNUSED:
- if (h->avctx->debug & FF_DEBUG_MMCO)
- av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n",
- h->mmco[i].short_pic_num, h->short_ref_count);
- remove_short(h, frame_num, structure ^ PICT_FRAME);
- break;
- case MMCO_SHORT2LONG:
+ if (mmco[i].opcode == MMCO_SHORT2UNUSED) {
+ if (h->avctx->debug & FF_DEBUG_MMCO)
+ av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n",
+ h->mmco[i].short_pic_num, h->short_ref_count);
+ remove_short(h, frame_num, structure ^ PICT_FRAME);
+ } else {
if (h->long_ref[mmco[i].long_arg] != pic)
remove_long(h, mmco[i].long_arg, 0);
@@ -678,6 +675,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
h->long_ref[mmco[i].long_arg]->long_ref = 1;
h->long_ref_count++;
}
+ }
break;
case MMCO_LONG2UNUSED:
j = pic_num_extract(h, mmco[i].long_arg, &structure);
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 4/6] avcodec/h264_refs: Use smaller scope, don't use av_uninit
2024-03-27 1:36 [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 2/6] avcodec/libvpxenc: Remove obsolete av_unused Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 3/6] avcodec/h264_refs: Rewrite code to make control flow clearer Andreas Rheinhardt
@ 2024-03-27 1:38 ` Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 5/6] avcodec/ratecontrol: Use forward declaration for AVExpr Andreas Rheinhardt
` (2 subsequent siblings)
5 siblings, 0 replies; 9+ messages in thread
From: Andreas Rheinhardt @ 2024-03-27 1:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
In particular, declare iterators with loop scope.
Also remove av_uninit while at it, because they
are now unnecessary due to the changes of the preceding
commit.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h264_refs.c | 121 ++++++++++++++++++-----------------------
1 file changed, 53 insertions(+), 68 deletions(-)
diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
index c2ba4b9b9e..99820142b9 100644
--- a/libavcodec/h264_refs.c
+++ b/libavcodec/h264_refs.c
@@ -38,8 +38,7 @@
static void pic_as_field(H264Ref *pic, const int parity)
{
- int i;
- for (i = 0; i < FF_ARRAY_ELEMS(pic->data); ++i) {
+ for (int i = 0; i < FF_ARRAY_ELEMS(pic->data); ++i) {
if (parity == PICT_BOTTOM_FIELD)
pic->data[i] += pic->linesize[i];
pic->reference = parity;
@@ -104,13 +103,12 @@ static int build_def_list(H264Ref *def, int def_len,
static int add_sorted(H264Picture **sorted, H264Picture * const *src,
int len, int limit, int dir)
{
- int i, best_poc;
int out_i = 0;
for (;;) {
- best_poc = dir ? INT_MIN : INT_MAX;
+ int best_poc = dir ? INT_MIN : INT_MAX;
- for (i = 0; i < len; i++) {
+ for (int i = 0; i < len; i++) {
const int poc = src[i]->poc;
if (((poc > limit) ^ dir) && ((poc < best_poc) ^ dir)) {
best_poc = poc;
@@ -134,12 +132,11 @@ static int mismatches_ref(const H264Context *h, const H264Picture *pic)
static void h264_initialise_ref_list(H264Context *h, H264SliceContext *sl)
{
- int i, len;
- int j;
+ int len;
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
H264Picture *sorted[32];
- int cur_poc, list;
+ int cur_poc;
int lens[2];
if (FIELD_PICTURE(h))
@@ -147,7 +144,7 @@ static void h264_initialise_ref_list(H264Context *h, H264SliceContext *sl)
else
cur_poc = h->cur_pic_ptr->poc;
- for (list = 0; list < 2; list++) {
+ for (int list = 0; list < 2; list++) {
len = add_sorted(sorted, h->short_ref, h->short_ref_count, cur_poc, 1 ^ list);
len += add_sorted(sorted + len, h->short_ref, h->short_ref_count, cur_poc, 0 ^ list);
av_assert0(len <= 32);
@@ -165,6 +162,7 @@ static void h264_initialise_ref_list(H264Context *h, H264SliceContext *sl)
}
if (lens[0] == lens[1] && lens[1] > 1) {
+ int i;
for (i = 0; i < lens[0] &&
sl->ref_list[0][i].parent->f->buf[0]->buffer ==
sl->ref_list[1][i].parent->f->buf[0]->buffer; i++);
@@ -184,14 +182,14 @@ static void h264_initialise_ref_list(H264Context *h, H264SliceContext *sl)
memset(&sl->ref_list[0][len], 0, sizeof(H264Ref) * (sl->ref_count[0] - len));
}
#ifdef TRACE
- for (i = 0; i < sl->ref_count[0]; i++) {
+ for (int i = 0; i < sl->ref_count[0]; i++) {
ff_tlog(h->avctx, "List0: %s fn:%d 0x%p\n",
(sl->ref_list[0][i].parent ? (sl->ref_list[0][i].parent->long_ref ? "LT" : "ST") : "??"),
sl->ref_list[0][i].pic_id,
sl->ref_list[0][i].data[0]);
}
if (sl->slice_type_nos == AV_PICTURE_TYPE_B) {
- for (i = 0; i < sl->ref_count[1]; i++) {
+ for (int i = 0; i < sl->ref_count[1]; i++) {
ff_tlog(h->avctx, "List1: %s fn:%d 0x%p\n",
(sl->ref_list[1][i].parent ? (sl->ref_list[1][i].parent->long_ref ? "LT" : "ST") : "??"),
sl->ref_list[1][i].pic_id,
@@ -200,8 +198,8 @@ static void h264_initialise_ref_list(H264Context *h, H264SliceContext *sl)
}
#endif
- for (j = 0; j<1+(sl->slice_type_nos == AV_PICTURE_TYPE_B); j++) {
- for (i = 0; i < sl->ref_count[j]; i++) {
+ for (int j = 0; j < 1 + (sl->slice_type_nos == AV_PICTURE_TYPE_B); j++) {
+ for (int i = 0; i < sl->ref_count[j]; i++) {
if (sl->ref_list[j][i].parent) {
if (mismatches_ref(h, sl->ref_list[j][i].parent)) {
av_log(h->avctx, AV_LOG_ERROR, "Discarding mismatching reference\n");
@@ -210,7 +208,7 @@ static void h264_initialise_ref_list(H264Context *h, H264SliceContext *sl)
}
}
}
- for (i = 0; i < sl->list_count; i++)
+ for (int i = 0; i < sl->list_count; i++)
h->default_ref[i] = sl->ref_list[i][0];
}
@@ -219,10 +217,9 @@ static void h264_initialise_ref_list(H264Context *h, H264SliceContext *sl)
*/
static void print_short_term(const H264Context *h)
{
- uint32_t i;
if (h->avctx->debug & FF_DEBUG_MMCO) {
av_log(h->avctx, AV_LOG_DEBUG, "short term list:\n");
- for (i = 0; i < h->short_ref_count; i++) {
+ for (uint32_t i = 0; i < h->short_ref_count; i++) {
H264Picture *pic = h->short_ref[i];
av_log(h->avctx, AV_LOG_DEBUG, "%"PRIu32" fn:%d poc:%d %p\n",
i, pic->frame_num, pic->poc, pic->f->data[0]);
@@ -235,10 +232,9 @@ static void print_short_term(const H264Context *h)
*/
static void print_long_term(const H264Context *h)
{
- uint32_t i;
if (h->avctx->debug & FF_DEBUG_MMCO) {
av_log(h->avctx, AV_LOG_DEBUG, "long term list:\n");
- for (i = 0; i < 16; i++) {
+ for (uint32_t i = 0; i < 16; i++) {
H264Picture *pic = h->long_ref[i];
if (pic) {
av_log(h->avctx, AV_LOG_DEBUG, "%"PRIu32" fn:%d poc:%d %p\n",
@@ -273,22 +269,21 @@ static int pic_num_extract(const H264Context *h, int pic_num, int *structure)
static void h264_fill_mbaff_ref_list(H264SliceContext *sl)
{
- int list, i, j;
- for (list = 0; list < sl->list_count; list++) {
- for (i = 0; i < sl->ref_count[list]; i++) {
+ for (int list = 0; list < sl->list_count; list++) {
+ for (int i = 0; i < sl->ref_count[list]; i++) {
const H264Ref *frame = &sl->ref_list[list][i];
H264Ref *field = &sl->ref_list[list][16 + 2 * i];
field[0] = *frame;
- for (j = 0; j < 3; j++)
+ for (int j = 0; j < 3; j++)
field[0].linesize[j] <<= 1;
field[0].reference = PICT_TOP_FIELD;
field[0].poc = field[0].parent->field_poc[0];
field[1] = field[0];
- for (j = 0; j < 3; j++)
+ for (int j = 0; j < 3; j++)
field[1].data[j] += frame->parent->f->linesize[j];
field[1].reference = PICT_BOTTOM_FIELD;
field[1].poc = field[1].parent->field_poc[1];
@@ -298,21 +293,19 @@ static void h264_fill_mbaff_ref_list(H264SliceContext *sl)
int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl)
{
- int list, index, pic_structure;
-
print_short_term(h);
print_long_term(h);
h264_initialise_ref_list(h, sl);
- for (list = 0; list < sl->list_count; list++) {
+ for (int list = 0; list < sl->list_count; list++) {
int pred = sl->curr_pic_num;
- for (index = 0; index < sl->nb_ref_modifications[list]; index++) {
+ for (int index = 0; index < sl->nb_ref_modifications[list]; index++) {
unsigned int modification_of_pic_nums_idc = sl->ref_modifications[list][index].op;
unsigned int val = sl->ref_modifications[list][index].val;
unsigned int pic_id;
- int i;
+ int i, pic_structure;
H264Picture *ref = NULL;
switch (modification_of_pic_nums_idc) {
@@ -396,13 +389,13 @@ int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl)
}
}
}
- for (list = 0; list < sl->list_count; list++) {
- for (index = 0; index < sl->ref_count[list]; index++) {
+ for (int list = 0; list < sl->list_count; list++) {
+ for (int index = 0; index < sl->ref_count[list]; index++) {
if ( !sl->ref_list[list][index].parent
|| (!FIELD_PICTURE(h) && (sl->ref_list[list][index].reference&3) != 3)) {
- int i;
av_log(h->avctx, AV_LOG_ERROR, "Missing reference picture, default is %d\n", h->default_ref[list].poc);
- for (i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++)
+
+ for (int i = 0; i < FF_ARRAY_ELEMS(h->last_pocs); i++)
h->last_pocs[i] = INT_MIN;
if (h->default_ref[list].parent
&& !(!FIELD_PICTURE(h) && (h->default_ref[list].reference&3) != 3))
@@ -433,16 +426,14 @@ int ff_h264_build_ref_list(H264Context *h, H264SliceContext *sl)
int ff_h264_decode_ref_pic_list_reordering(H264SliceContext *sl, void *logctx)
{
- int list, index;
-
sl->nb_ref_modifications[0] = 0;
sl->nb_ref_modifications[1] = 0;
- for (list = 0; list < sl->list_count; list++) {
+ for (int list = 0; list < sl->list_count; list++) {
if (!get_bits1(&sl->gb)) // ref_pic_list_modification_flag_l[01]
continue;
- for (index = 0; ; index++) {
+ for (int index = 0; ; index++) {
unsigned int op = get_ue_golomb_31(&sl->gb);
if (op == 3)
@@ -479,11 +470,10 @@ int ff_h264_decode_ref_pic_list_reordering(H264SliceContext *sl, void *logctx)
*/
static inline int unreference_pic(H264Context *h, H264Picture *pic, int refmask)
{
- int i;
if (pic->reference &= refmask) {
return 0;
} else {
- for(i = 0; h->delayed_pic[i]; i++)
+ for (int i = 0; h->delayed_pic[i]; i++)
if(pic == h->delayed_pic[i]){
pic->reference = DELAYED_PIC_REF;
break;
@@ -502,9 +492,7 @@ static inline int unreference_pic(H264Context *h, H264Picture *pic, int refmask)
*/
static H264Picture *find_short(H264Context *h, int frame_num, int *idx)
{
- int i;
-
- for (i = 0; i < h->short_ref_count; i++) {
+ for (int i = 0; i < h->short_ref_count; i++) {
H264Picture *pic = h->short_ref[i];
if (h->avctx->debug & FF_DEBUG_MMCO)
av_log(h->avctx, AV_LOG_DEBUG, "%d %d %p\n", i, pic->frame_num, pic);
@@ -575,11 +563,8 @@ static H264Picture *remove_long(H264Context *h, int i, int ref_mask)
void ff_h264_remove_all_refs(H264Context *h)
{
- int i;
-
- for (i = 0; i < 16; i++) {
+ for (int i = 0; i < 16; i++)
remove_long(h, i, 0);
- }
assert(h->long_ref_count == 0);
if (h->short_ref_count && !h->last_pic_for_ec.f->data[0]) {
@@ -587,7 +572,7 @@ void ff_h264_remove_all_refs(H264Context *h)
ff_h264_ref_picture(&h->last_pic_for_ec, h->short_ref[0]);
}
- for (i = 0; i < h->short_ref_count; i++) {
+ for (int i = 0; i < h->short_ref_count; i++) {
unreference_pic(h, h->short_ref[i], 0);
h->short_ref[i] = NULL;
}
@@ -622,10 +607,8 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
{
MMCO *mmco = h->mmco;
int mmco_count;
- int i, av_uninit(j);
int pps_ref_count[2] = {0};
int current_ref_assigned = 0, err = 0;
- H264Picture *av_uninit(pic);
if (!h->ps.sps) {
av_log(h->avctx, AV_LOG_ERROR, "SPS is unset\n");
@@ -640,17 +623,18 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
if ((h->avctx->debug & FF_DEBUG_MMCO) && mmco_count == 0)
av_log(h->avctx, AV_LOG_DEBUG, "no mmco here\n");
- for (i = 0; i < mmco_count; i++) {
- int av_uninit(structure), av_uninit(frame_num);
+ for (int i = 0; i < mmco_count; i++) {
if (h->avctx->debug & FF_DEBUG_MMCO)
av_log(h->avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode,
h->mmco[i].short_pic_num, h->mmco[i].long_arg);
switch (mmco[i].opcode) {
case MMCO_SHORT2UNUSED:
- case MMCO_SHORT2LONG:
- frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure);
- pic = find_short(h, frame_num, &j);
+ case MMCO_SHORT2LONG: {
+ int structure, j;
+ int frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure);
+ H264Picture *pic = find_short(h, frame_num, &j);
+
if (!pic) {
if (mmco[i].opcode != MMCO_SHORT2LONG ||
!h->long_ref[mmco[i].long_arg] ||
@@ -677,14 +661,16 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
}
}
break;
- case MMCO_LONG2UNUSED:
- j = pic_num_extract(h, mmco[i].long_arg, &structure);
- pic = h->long_ref[j];
+ }
+ case MMCO_LONG2UNUSED: {
+ int structure, j = pic_num_extract(h, mmco[i].long_arg, &structure);
+ H264Picture *pic = h->long_ref[j];
if (pic) {
remove_long(h, j, structure ^ PICT_FRAME);
} else if (h->avctx->debug & FF_DEBUG_MMCO)
av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref long failure\n");
break;
+ }
case MMCO_LONG:
// Comment below left from previous code as it is an interesting note.
/* First field in pair is in short term list or
@@ -700,7 +686,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
/* make sure the current picture is not already assigned as a long ref */
if (h->cur_pic_ptr->long_ref) {
- for (j = 0; j < FF_ARRAY_ELEMS(h->long_ref); j++) {
+ for (int j = 0; j < FF_ARRAY_ELEMS(h->long_ref); j++) {
if (h->long_ref[j] == h->cur_pic_ptr) {
if (j != mmco[i].long_arg)
av_log(h->avctx, AV_LOG_ERROR, "mmco: cannot assign current picture to 2 long term references\n");
@@ -724,21 +710,19 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
case MMCO_SET_MAX_LONG:
assert(mmco[i].long_arg <= 16);
// just remove the long term which index is greater than new max
- for (j = mmco[i].long_arg; j < 16; j++) {
+ for (int j = mmco[i].long_arg; j < 16; j++)
remove_long(h, j, 0);
- }
break;
case MMCO_RESET:
while (h->short_ref_count) {
remove_short(h, h->short_ref[0]->frame_num, 0);
}
- for (j = 0; j < 16; j++) {
+ for (int j = 0; j < 16; j++)
remove_long(h, j, 0);
- }
h->poc.frame_num = h->cur_pic_ptr->frame_num = 0;
h->mmco_reset = 1;
h->cur_pic_ptr->mmco_reset = 1;
- for (j = 0; j < FF_ARRAY_ELEMS(h->last_pocs); j++)
+ for (int j = 0; j < FF_ARRAY_ELEMS(h->last_pocs); j++)
h->last_pocs[j] = INT_MIN;
break;
default: av_assert0(0);
@@ -762,7 +746,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
"(first field is long term)\n");
err = AVERROR_INVALIDDATA;
} else {
- pic = remove_short(h, h->cur_pic_ptr->frame_num, 0);
+ H264Picture *pic = remove_short(h, h->cur_pic_ptr->frame_num, 0);
if (pic) {
av_log(h->avctx, AV_LOG_ERROR, "illegal short term buffer state detected\n");
err = AVERROR_INVALIDDATA;
@@ -791,6 +775,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
err = AVERROR_INVALIDDATA;
if (h->long_ref_count && !h->short_ref_count) {
+ int i;
for (i = 0; i < 16; ++i)
if (h->long_ref[i])
break;
@@ -798,13 +783,13 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
assert(i < 16);
remove_long(h, i, 0);
} else {
- pic = h->short_ref[h->short_ref_count - 1];
+ H264Picture *pic = h->short_ref[h->short_ref_count - 1];
remove_short(h, pic->frame_num, 0);
}
}
- for (i = 0; i<h->short_ref_count; i++) {
- pic = h->short_ref[i];
+ for (int i = 0; i < h->short_ref_count; i++) {
+ H264Picture *pic = h->short_ref[i];
if (pic->invalid_gap) {
int d = av_mod_uintp2(h->cur_pic_ptr->frame_num - pic->frame_num, h->ps.sps->log2_max_frame_num);
if (d > h->ps.sps->ref_frame_count)
@@ -815,7 +800,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
print_short_term(h);
print_long_term(h);
- for (i = 0; i < FF_ARRAY_ELEMS(h->ps.pps_list); i++) {
+ for (int i = 0; i < FF_ARRAY_ELEMS(h->ps.pps_list); i++) {
if (h->ps.pps_list[i]) {
const PPS *pps = h->ps.pps_list[i];
pps_ref_count[0] = FFMAX(pps_ref_count[0], pps->ref_count[0]);
@@ -843,7 +828,6 @@ out:
int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb,
const H2645NAL *nal, void *logctx)
{
- int i;
MMCO *mmco = sl->mmco;
int nb_mmco = 0;
@@ -858,6 +842,7 @@ int ff_h264_decode_ref_pic_marking(H264SliceContext *sl, GetBitContext *gb,
} else {
sl->explicit_ref_marking = get_bits1(gb);
if (sl->explicit_ref_marking) {
+ int i;
for (i = 0; i < FF_ARRAY_ELEMS(sl->mmco); i++) {
MMCOOpcode opcode = get_ue_golomb_31(gb);
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 5/6] avcodec/ratecontrol: Use forward declaration for AVExpr
2024-03-27 1:36 [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it Andreas Rheinhardt
` (2 preceding siblings ...)
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 4/6] avcodec/h264_refs: Use smaller scope, don't use av_uninit Andreas Rheinhardt
@ 2024-03-27 1:38 ` Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 6/6] avutil/opt: Avoid av_uninit Andreas Rheinhardt
2024-03-27 17:29 ` [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it James Zern via ffmpeg-devel
5 siblings, 0 replies; 9+ messages in thread
From: Andreas Rheinhardt @ 2024-03-27 1:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Avoids including eval.h everywhere where mpegvideo.h
is included.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/ratecontrol.h | 4 +---
1 file changed, 1 insertion(+), 3 deletions(-)
diff --git a/libavcodec/ratecontrol.h b/libavcodec/ratecontrol.h
index 4de80fad90..1f44b44341 100644
--- a/libavcodec/ratecontrol.h
+++ b/libavcodec/ratecontrol.h
@@ -28,9 +28,7 @@
* ratecontrol header.
*/
-#include <stdio.h>
#include <stdint.h>
-#include "libavutil/eval.h"
typedef struct Predictor{
double coeff;
@@ -80,7 +78,7 @@ typedef struct RateControlContext{
int frame_count[5];
int last_non_b_pict_type;
- AVExpr * rc_eq_eval;
+ struct AVExpr *rc_eq_eval;
}RateControlContext;
struct MpegEncContext;
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* [FFmpeg-devel] [PATCH 6/6] avutil/opt: Avoid av_uninit
2024-03-27 1:36 [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it Andreas Rheinhardt
` (3 preceding siblings ...)
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 5/6] avcodec/ratecontrol: Use forward declaration for AVExpr Andreas Rheinhardt
@ 2024-03-27 1:38 ` Andreas Rheinhardt
2024-03-27 17:29 ` [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it James Zern via ffmpeg-devel
5 siblings, 0 replies; 9+ messages in thread
From: Andreas Rheinhardt @ 2024-03-27 1:38 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
GCC 9-13 do not emit warnings for this at all optimization
levels even when -Wmaybe-uninitialized is not disabled.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavutil/opt.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/libavutil/opt.c b/libavutil/opt.c
index 685206f416..fc54a5386d 100644
--- a/libavutil/opt.c
+++ b/libavutil/opt.c
@@ -1859,7 +1859,6 @@ int av_opt_set_from_string(void *ctx, const char *opts,
{
int ret, count = 0;
const char *dummy_shorthand = NULL;
- char *av_uninit(parsed_key), *av_uninit(value);
const char *key;
if (!opts)
@@ -1868,6 +1867,7 @@ int av_opt_set_from_string(void *ctx, const char *opts,
shorthand = &dummy_shorthand;
while (*opts) {
+ char *parsed_key, *value;
ret = av_opt_get_key_value(&opts, key_val_sep, pairs_sep,
*shorthand ? AV_OPT_FLAG_IMPLICIT_KEY : 0,
&parsed_key, &value);
--
2.40.1
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it
2024-03-27 1:36 [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it Andreas Rheinhardt
` (4 preceding siblings ...)
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 6/6] avutil/opt: Avoid av_uninit Andreas Rheinhardt
@ 2024-03-27 17:29 ` James Zern via ffmpeg-devel
5 siblings, 0 replies; 9+ messages in thread
From: James Zern via ffmpeg-devel @ 2024-03-27 17:29 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: James Zern
On Tue, Mar 26, 2024 at 6:36 PM Andreas Rheinhardt
<andreas.rheinhardt@outlook.com> wrote:
>
> Also rewrite the code so that a variable that is only used
> depending upon CONFIG_LIBVPX_VP9_ENCODER is not declared
> outside of the #if block.
> (The variable was declared with av_uninit, but it should have been
> av_unused, as the former does not work for all compilers.)
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/libvpxenc.c | 19 ++++++++++---------
> 1 file changed, 10 insertions(+), 9 deletions(-)
>
lgtm.
> diff --git a/libavcodec/libvpxenc.c b/libavcodec/libvpxenc.c
> index 4b89e47e83..ee903a4e5c 100644
> --- a/libavcodec/libvpxenc.c
> +++ b/libavcodec/libvpxenc.c
> @@ -357,19 +357,20 @@ static int frame_data_submit(AVCodecContext *avctx, AVFifo *fifo,
> const struct vpx_codec_enc_cfg *enccfg = ctx->encoder.config.enc;
>
> FrameData fd = { .pts = frame->pts };
> -
> - AVFrameSideData *av_uninit(sd);
> int ret;
>
> #if CONFIG_LIBVPX_VP9_ENCODER
> - // Keep HDR10+ if it has bit depth higher than 8 and
> - // it has PQ trc (SMPTE2084).
> - sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
> - if (avctx->codec_id == AV_CODEC_ID_VP9 && sd &&
> + if (avctx->codec_id == AV_CODEC_ID_VP9 &&
> + // Keep HDR10+ if it has bit depth higher than 8 and
> + // it has PQ trc (SMPTE2084).
> enccfg->g_bit_depth > 8 && avctx->color_trc == AVCOL_TRC_SMPTE2084) {
> - fd.hdr10_plus = av_buffer_ref(sd->buf);
> - if (!fd.hdr10_plus)
> - return AVERROR(ENOMEM);
> + const AVFrameSideData *sd = av_frame_get_side_data(frame, AV_FRAME_DATA_DYNAMIC_HDR_PLUS);
> +
> + if (sd) {
> + fd.hdr10_plus = av_buffer_ref(sd->buf);
> + if (!fd.hdr10_plus)
> + return AVERROR(ENOMEM);
> + }
> }
> #endif
>
> --
> 2.40.1
>
> _______________________________________________
> ffmpeg-devel mailing list
> ffmpeg-devel@ffmpeg.org
> https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
>
> To unsubscribe, visit link above, or email
> ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 2/6] avcodec/libvpxenc: Remove obsolete av_unused
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 2/6] avcodec/libvpxenc: Remove obsolete av_unused Andreas Rheinhardt
@ 2024-03-27 17:30 ` James Zern via ffmpeg-devel
0 siblings, 0 replies; 9+ messages in thread
From: James Zern via ffmpeg-devel @ 2024-03-27 17:30 UTC (permalink / raw)
To: FFmpeg development discussions and patches; +Cc: James Zern
On Tue, Mar 26, 2024 at 6:38 PM Andreas Rheinhardt
<andreas.rheinhardt@outlook.com> wrote:
>
> Forgotten in 753074721bd414874d18c372c491bdc6323fa3bf.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/libvpxenc.c | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
lgtm.
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: [FFmpeg-devel] [PATCH 3/6] avcodec/h264_refs: Rewrite code to make control flow clearer
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 3/6] avcodec/h264_refs: Rewrite code to make control flow clearer Andreas Rheinhardt
@ 2024-03-29 20:25 ` Andreas Rheinhardt
0 siblings, 0 replies; 9+ messages in thread
From: Andreas Rheinhardt @ 2024-03-29 20:25 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> While this change IMO makes the control flow clearer
> for the human reader, it is especially important for
> GCC: It erroneously believes that it is possible to
> enter the SHORT2(UNUSED|LONG) cases without having
> entered the preceding block that initializes pic,
> frame_num, structure and j; it would emit -Wmaybe-uninitialized
> warnings for these variables if they were not pseudo-
> initialized with av_uninit(). This patch allows to remove
> the latter.
>
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/h264_refs.c | 22 ++++++++++------------
> 1 file changed, 10 insertions(+), 12 deletions(-)
>
> diff --git a/libavcodec/h264_refs.c b/libavcodec/h264_refs.c
> index 9bc7b20988..c2ba4b9b9e 100644
> --- a/libavcodec/h264_refs.c
> +++ b/libavcodec/h264_refs.c
> @@ -646,8 +646,9 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
> av_log(h->avctx, AV_LOG_DEBUG, "mmco:%d %d %d\n", h->mmco[i].opcode,
> h->mmco[i].short_pic_num, h->mmco[i].long_arg);
>
> - if (mmco[i].opcode == MMCO_SHORT2UNUSED ||
> - mmco[i].opcode == MMCO_SHORT2LONG) {
> + switch (mmco[i].opcode) {
> + case MMCO_SHORT2UNUSED:
> + case MMCO_SHORT2LONG:
> frame_num = pic_num_extract(h, mmco[i].short_pic_num, &structure);
> pic = find_short(h, frame_num, &j);
> if (!pic) {
> @@ -659,16 +660,12 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
> }
> continue;
> }
> - }
> -
> - switch (mmco[i].opcode) {
> - case MMCO_SHORT2UNUSED:
> - if (h->avctx->debug & FF_DEBUG_MMCO)
> - av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n",
> - h->mmco[i].short_pic_num, h->short_ref_count);
> - remove_short(h, frame_num, structure ^ PICT_FRAME);
> - break;
> - case MMCO_SHORT2LONG:
> + if (mmco[i].opcode == MMCO_SHORT2UNUSED) {
> + if (h->avctx->debug & FF_DEBUG_MMCO)
> + av_log(h->avctx, AV_LOG_DEBUG, "mmco: unref short %d count %d\n",
> + h->mmco[i].short_pic_num, h->short_ref_count);
> + remove_short(h, frame_num, structure ^ PICT_FRAME);
> + } else {
> if (h->long_ref[mmco[i].long_arg] != pic)
> remove_long(h, mmco[i].long_arg, 0);
>
> @@ -678,6 +675,7 @@ int ff_h264_execute_ref_pic_marking(H264Context *h)
> h->long_ref[mmco[i].long_arg]->long_ref = 1;
> h->long_ref_count++;
> }
> + }
> break;
> case MMCO_LONG2UNUSED:
> j = pic_num_extract(h, mmco[i].long_arg, &structure);
Will apply the rest of this patchset tomorrow unless there are objections.
- Andreas
_______________________________________________
ffmpeg-devel mailing list
ffmpeg-devel@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
To unsubscribe, visit link above, or email
ffmpeg-devel-request@ffmpeg.org with subject "unsubscribe".
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-03-29 20:25 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2024-03-27 1:36 [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 2/6] avcodec/libvpxenc: Remove obsolete av_unused Andreas Rheinhardt
2024-03-27 17:30 ` James Zern via ffmpeg-devel
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 3/6] avcodec/h264_refs: Rewrite code to make control flow clearer Andreas Rheinhardt
2024-03-29 20:25 ` Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 4/6] avcodec/h264_refs: Use smaller scope, don't use av_uninit Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 5/6] avcodec/ratecontrol: Use forward declaration for AVExpr Andreas Rheinhardt
2024-03-27 1:38 ` [FFmpeg-devel] [PATCH 6/6] avutil/opt: Avoid av_uninit Andreas Rheinhardt
2024-03-27 17:29 ` [FFmpeg-devel] [PATCH 1/6] avcodec/libvpxenc: Only search for side data when intending to use it James Zern via ffmpeg-devel
Git Inbox Mirror of the ffmpeg-devel mailing list - see https://ffmpeg.org/mailman/listinfo/ffmpeg-devel
This inbox may be cloned and mirrored by anyone:
git clone --mirror https://master.gitmailbox.com/ffmpegdev/0 ffmpegdev/git/0.git
# If you have public-inbox 1.1+ installed, you may
# initialize and index your mirror using the following commands:
public-inbox-init -V2 ffmpegdev ffmpegdev/ https://master.gitmailbox.com/ffmpegdev \
ffmpegdev@gitmailbox.com
public-inbox-index ffmpegdev
Example config snippet for mirrors.
AGPL code for this site: git clone https://public-inbox.org/public-inbox.git