* [FFmpeg-devel] [PATCH 2/7] lavc: add AV_CODEC_EXPORT_DATA_ERROR
2023-07-21 13:37 [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata J. Dekker
@ 2023-07-21 13:37 ` J. Dekker
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 3/7] lavc/error_resilience: fill ecinfo J. Dekker
` (7 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: J. Dekker @ 2023-07-21 13:37 UTC (permalink / raw)
To: ffmpeg-devel
Add an option to avcodec to allow supported decoders to optionally
output information about error resilience as sidedata.
Co-Authored-By: Thomas Guillem <thomas@gllm.fr>
Signed-off-by: J. Dekker <jdek@itanimul.li>
---
libavcodec/avcodec.h | 5 +++++
libavcodec/options_table.h | 1 +
libavcodec/version.h | 2 +-
3 files changed, 7 insertions(+), 1 deletion(-)
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index fe41ecc3c9..7400604fc5 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -410,6 +410,11 @@ typedef struct RcOverride{
* Do not apply film grain, export it instead.
*/
#define AV_CODEC_EXPORT_DATA_FILM_GRAIN (1 << 3)
+/**
+ * Decoding only.
+ * Export the AVECInfo structure through frame side data.
+ */
+#define AV_CODEC_EXPORT_DATA_ERROR (1 << 4)
/**
* The decoder will keep a reference to the frame and may reuse it later.
diff --git a/libavcodec/options_table.h b/libavcodec/options_table.h
index bb4b894b06..0a1dc4b062 100644
--- a/libavcodec/options_table.h
+++ b/libavcodec/options_table.h
@@ -91,6 +91,7 @@ static const AVOption avcodec_options[] = {
{"prft", "export Producer Reference Time through packet side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_PRFT}, INT_MIN, INT_MAX, A|V|S|E, "export_side_data"},
{"venc_params", "export video encoding parameters through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_VIDEO_ENC_PARAMS}, INT_MIN, INT_MAX, V|D, "export_side_data"},
{"film_grain", "export film grain parameters through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_FILM_GRAIN}, INT_MIN, INT_MAX, V|D, "export_side_data"},
+{"error_info", "export error info through frame side data", 0, AV_OPT_TYPE_CONST, {.i64 = AV_CODEC_EXPORT_DATA_ERROR}, INT_MIN, INT_MAX, V|D, "export_side_data"},
{"time_base", NULL, OFFSET(time_base), AV_OPT_TYPE_RATIONAL, {.dbl = 0}, 0, INT_MAX},
{"g", "set the group of picture (GOP) size", OFFSET(gop_size), AV_OPT_TYPE_INT, {.i64 = 12 }, INT_MIN, INT_MAX, V|E},
{"ar", "set audio sampling rate (in Hz)", OFFSET(sample_rate), AV_OPT_TYPE_INT, {.i64 = DEFAULT }, 0, INT_MAX, A|D|E},
diff --git a/libavcodec/version.h b/libavcodec/version.h
index 9411511e04..728ab8839d 100644
--- a/libavcodec/version.h
+++ b/libavcodec/version.h
@@ -29,7 +29,7 @@
#include "version_major.h"
-#define LIBAVCODEC_VERSION_MINOR 22
+#define LIBAVCODEC_VERSION_MINOR 23
#define LIBAVCODEC_VERSION_MICRO 100
#define LIBAVCODEC_VERSION_INT AV_VERSION_INT(LIBAVCODEC_VERSION_MAJOR, \
--
2.41.0
_______________________________________________
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] 13+ messages in thread
* [FFmpeg-devel] [PATCH 3/7] lavc/error_resilience: fill ecinfo
2023-07-21 13:37 [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata J. Dekker
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 2/7] lavc: add AV_CODEC_EXPORT_DATA_ERROR J. Dekker
@ 2023-07-21 13:37 ` J. Dekker
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 4/7] lavc: set decode_error_flags when ec active J. Dekker
` (6 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: J. Dekker @ 2023-07-21 13:37 UTC (permalink / raw)
To: ffmpeg-devel
Fill ECInfo inside error resilience using references set by the decoder.
Co-Authored-By: Thomas Guillem <thomas@gllm.fr>
Signed-off-by: J. Dekker <jdek@itanimul.li>
---
libavcodec/error_resilience.c | 91 +++++++++++++++++++++++++++++------
libavcodec/error_resilience.h | 4 +-
2 files changed, 79 insertions(+), 16 deletions(-)
diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index 2aa6f1d864..c1417ecf07 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -28,6 +28,7 @@
#include <limits.h>
#include "libavutil/internal.h"
+#include "libavutil/ec.h"
#include "avcodec.h"
#include "error_resilience.h"
#include "me_cmp.h"
@@ -411,7 +412,7 @@ static void guess_mv(ERContext *s)
num_avail = 0;
if (s->last_pic.motion_val[0])
- ff_thread_await_progress(s->last_pic.tf, mb_height-1, 0);
+ ff_thread_await_progress(s->last_pic.tf, INT_MAX, 0);
for (i = 0; i < mb_width * mb_height; i++) {
const int mb_xy = s->mb_index2xy[i];
int f = 0;
@@ -889,25 +890,61 @@ void ff_er_add_slice(ERContext *s, int startx, int starty,
}
}
-void ff_er_frame_end(ERContext *s)
+static void
+er_fill_info_ref(ERContext *s)
+{
+ uint64_t acc_ok = 0, acc_err = 0;
+ av_assert0(s->cur_pic.info);
+
+ if (s->cur_pic.f->pict_type != AV_PICTURE_TYPE_I) {
+ ERPicture *reffs[2] = {&s->last_pic, &s->next_pic};
+ int i, nb_ref_pics = s->cur_pic.f->pict_type == AV_PICTURE_TYPE_B ? 2 : 1;
+
+ for (i = 0; i < nb_ref_pics; i++) {
+ ERPicture *reff = reffs[i];
+
+ if (reff->info == NULL)
+ continue;
+
+ ff_thread_await_progress(reff->tf, INT_MAX, 0);
+
+ /* should check more accurately how refs are used */
+ if (reff->info->error == 0 && reff->info->ref_error == 0)
+ continue;
+
+ if (acc_err < (reff->info->error + reff->info->ref_error)){
+ acc_err = reff->info->error + reff->info->ref_error;
+ acc_ok = reff->info->ok + reff->info->ref_ok;
+ }
+ }
+ }
+
+ s->cur_pic.info->ref_error = acc_err;
+ s->cur_pic.info->ref_ok = acc_ok;
+}
+
+int ff_er_frame_end(ERContext *s)
{
int *linesize = NULL;
- int i, mb_x, mb_y, error, error_type, dc_error, mv_error, ac_error;
+ int i, mb_x, mb_y, error, error_type, dc_error, mv_error, ac_error, terror;
int distance;
int threshold_part[4] = { 100, 100, 100 };
int threshold = 50;
int is_intra_likely;
int size = s->b8_stride * 2 * s->mb_height;
+
/* We do not support ER of field pictures yet,
* though it should not crash if enabled. */
- if (!s->avctx->error_concealment || !atomic_load(&s->error_count) ||
- s->avctx->lowres ||
- !er_supported(s) ||
- atomic_load(&s->error_count) == 3 * s->mb_width *
- (s->avctx->skip_top + s->avctx->skip_bottom)) {
- return;
+ if (!s->avctx->error_concealment || s->avctx->lowres || !er_supported(s))
+ return 0;
+
+ if (!atomic_load(&s->error_count) ||
+ atomic_load(&s->error_count) == 3 * s->mb_width * (s->avctx->skip_top + s->avctx->skip_bottom))
+ {
+ goto end_find_ref_errs;
}
+
linesize = s->cur_pic.f->linesize;
if ( s->avctx->codec_id == AV_CODEC_ID_MPEG2VIDEO
@@ -921,7 +958,7 @@ void ff_er_frame_end(ERContext *s)
if (mb_x == s->mb_width) {
av_log(s->avctx, AV_LOG_DEBUG, "ignoring last missing slice\n");
- return;
+ goto end_find_ref_errs;
}
}
@@ -960,7 +997,7 @@ void ff_er_frame_end(ERContext *s)
s->cur_pic.ref_index[i] = NULL;
s->cur_pic.motion_val[i] = NULL;
}
- return;
+ goto end_find_ref_errs;
}
}
@@ -1100,10 +1137,12 @@ void ff_er_frame_end(ERContext *s)
}
#endif
- dc_error = ac_error = mv_error = 0;
+ terror = dc_error = ac_error = mv_error = 0;
for (i = 0; i < s->mb_num; i++) {
const int mb_xy = s->mb_index2xy[i];
int error = s->error_status_table[mb_xy];
+ if (error)
+ terror++;
if (error & ER_DC_ERROR)
dc_error++;
if (error & ER_AC_ERROR)
@@ -1111,10 +1150,9 @@ void ff_er_frame_end(ERContext *s)
if (error & ER_MV_ERROR)
mv_error++;
}
- av_log(s->avctx, AV_LOG_INFO, "concealing %d DC, %d AC, %d MV errors in %c frame\n",
- dc_error, ac_error, mv_error, av_get_picture_type_char(s->cur_pic.f->pict_type));
- s->cur_pic.f->decode_error_flags |= FF_DECODE_ERROR_CONCEALMENT_ACTIVE;
+ fprintf(stderr, "concealing %d DC, %d AC, %d MV errors in %c frame: %d\n",
+ dc_error, ac_error, mv_error, av_get_picture_type_char(s->cur_pic.f->pict_type), terror * 256);
is_intra_likely = is_intra_more_likely(s);
@@ -1349,7 +1387,30 @@ void ff_er_frame_end(ERContext *s)
s->cur_pic.motion_val[i] = NULL;
}
+ av_assert0(terror);
+ if (s->cur_pic.info) {
+ /* assumes 16x16 mbs */
+ s->cur_pic.info->error = terror * 256;
+ s->cur_pic.info->ok = (s->mb_num - terror) * 256;
+ er_fill_info_ref(s);
+ }
+
+ memset(&s->cur_pic, 0, sizeof(ERPicture));
+ memset(&s->last_pic, 0, sizeof(ERPicture));
+ memset(&s->next_pic, 0, sizeof(ERPicture));
+
+ return 1;
+
+end_find_ref_errs:
+ if (s->cur_pic.info)
+ {
+ er_fill_info_ref(s);
+ s->cur_pic.info->error = s->cur_pic.info->ok = 0;
+ }
+
memset(&s->cur_pic, 0, sizeof(ERPicture));
memset(&s->last_pic, 0, sizeof(ERPicture));
memset(&s->next_pic, 0, sizeof(ERPicture));
+
+ return 0;
}
diff --git a/libavcodec/error_resilience.h b/libavcodec/error_resilience.h
index 47cc8a4fc6..97479d2c0c 100644
--- a/libavcodec/error_resilience.h
+++ b/libavcodec/error_resilience.h
@@ -25,6 +25,7 @@
#include "avcodec.h"
#include "me_cmp.h"
#include "threadframe.h"
+#include "libavutil/ec.h"
///< current MB is the first after a resync marker
#define VP_START 1
@@ -48,6 +49,7 @@ typedef struct ERPicture {
uint32_t *mb_type;
int field_picture;
+ AVECInfo *info;
} ERPicture;
typedef struct ERContext {
@@ -90,7 +92,7 @@ typedef struct ERContext {
} ERContext;
void ff_er_frame_start(ERContext *s);
-void ff_er_frame_end(ERContext *s);
+int ff_er_frame_end(ERContext *s);
void ff_er_add_slice(ERContext *s, int startx, int starty, int endx, int endy,
int status);
--
2.41.0
_______________________________________________
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] 13+ messages in thread
* [FFmpeg-devel] [PATCH 4/7] lavc: set decode_error_flags when ec active
2023-07-21 13:37 [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata J. Dekker
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 2/7] lavc: add AV_CODEC_EXPORT_DATA_ERROR J. Dekker
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 3/7] lavc/error_resilience: fill ecinfo J. Dekker
@ 2023-07-21 13:37 ` J. Dekker
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 5/7] lavc/h264: export ecinfo J. Dekker
` (5 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: J. Dekker @ 2023-07-21 13:37 UTC (permalink / raw)
To: ffmpeg-devel
FF_DECODE_ERROR_CONCEALMENT_ACTIVE should be set when ec is active on
supported decoders.
Co-Authored-By: Thomas Guillem <thomas@gllm.fr>
Signed-off-by: J. Dekker <jdek@itanimul.li>
---
libavcodec/h263dec.c | 6 ++++--
libavcodec/mpeg12dec.c | 3 ++-
libavcodec/mss2.c | 8 +++++---
libavcodec/rv10.c | 10 ++++++++--
libavcodec/rv34.c | 12 +++++++++---
libavcodec/vc1dec.c | 6 ++++--
6 files changed, 32 insertions(+), 13 deletions(-)
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 68a618a7ed..f3b9f09303 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -620,8 +620,10 @@ retry:
av_assert1(s->bitstream_buffer_size == 0);
frame_end:
- if (!s->studio_profile)
- ff_er_frame_end(&s->er);
+ if (!s->studio_profile) {
+ if (ff_er_frame_end(&s->er) > 0)
+ s->current_picture.f->decode_error_flags |= FF_DECODE_ERROR_CONCEALMENT_ACTIVE;
+ }
if (avctx->hwaccel) {
ret = avctx->hwaccel->end_frame(avctx);
diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c
index 27b45c6fc4..82a1e56b67 100644
--- a/libavcodec/mpeg12dec.c
+++ b/libavcodec/mpeg12dec.c
@@ -2038,7 +2038,8 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
if (/* s->mb_y << field_pic == s->mb_height && */ !s->first_field && !s1->first_slice) {
/* end of image */
- ff_er_frame_end(&s->er);
+ if (ff_er_frame_end(&s->er) > 0)
+ s->current_picture_ptr->f->decode_error_flags |= FF_DECODE_ERROR_CONCEALMENT_ACTIVE;
ff_mpv_frame_end(s);
diff --git a/libavcodec/mss2.c b/libavcodec/mss2.c
index 98103f7fed..851346b0ad 100644
--- a/libavcodec/mss2.c
+++ b/libavcodec/mss2.c
@@ -421,8 +421,12 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size,
ff_vc1_decode_blocks(v);
+ f = s->current_picture.f;
+
if (v->end_mb_x == s->mb_width && s->end_mb_y == s->mb_height) {
- ff_er_frame_end(&s->er);
+ if (ff_er_frame_end(&s->er) > 0)
+ f->decode_error_flags |= FF_DECODE_ERROR_CONCEALMENT_ACTIVE;
+
} else {
av_log(v->s.avctx, AV_LOG_WARNING,
"disabling error correction due to block count mismatch %dx%d != %dx%d\n",
@@ -431,8 +435,6 @@ static int decode_wmv9(AVCodecContext *avctx, const uint8_t *buf, int buf_size,
ff_mpv_frame_end(s);
- f = s->current_picture.f;
-
if (v->respic == 3) {
ctx->dsp.upsample_plane(f->data[0], f->linesize[0], w, h);
ctx->dsp.upsample_plane(f->data[1], f->linesize[1], w+1 >> 1, h+1 >> 1);
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index bb1ead5002..09a1d4dba6 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -440,6 +440,12 @@ static av_cold int rv10_decode_end(AVCodecContext *avctx)
return 0;
}
+static void rv10_er_frame_end(MpegEncContext *s)
+{
+ if (ff_er_frame_end(&s->er) > 0)
+ s->current_picture_ptr->f->decode_error_flags |= FF_DECODE_ERROR_CONCEALMENT_ACTIVE;
+}
+
static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
int buf_size, int buf_size2, int whole_size)
{
@@ -477,7 +483,7 @@ static int rv10_decode_packet(AVCodecContext *avctx, const uint8_t *buf,
if ((s->mb_x == 0 && s->mb_y == 0) || !s->current_picture_ptr) {
// FIXME write parser so we always have complete frames?
if (s->current_picture_ptr) {
- ff_er_frame_end(&s->er);
+ rv10_er_frame_end(s);
ff_mpv_frame_end(s);
s->mb_x = s->mb_y = s->resync_mb_x = s->resync_mb_y = 0;
}
@@ -649,7 +655,7 @@ static int rv10_decode_frame(AVCodecContext *avctx, AVFrame *pict,
}
if (s->current_picture_ptr && s->mb_y >= s->mb_height) {
- ff_er_frame_end(&s->er);
+ rv10_er_frame_end(s);
ff_mpv_frame_end(s);
if (s->pict_type == AV_PICTURE_TYPE_B || s->low_delay) {
diff --git a/libavcodec/rv34.c b/libavcodec/rv34.c
index 51f18147af..c6231adf5f 100644
--- a/libavcodec/rv34.c
+++ b/libavcodec/rv34.c
@@ -1554,13 +1554,19 @@ static int get_slice_offset(AVCodecContext *avctx, const uint8_t *buf, int n, in
return buf_size;
}
+static void rv34_er_frame_end(MpegEncContext *s)
+{
+ if (ff_er_frame_end(&s->er) > 0)
+ s->current_picture_ptr->f->decode_error_flags |= FF_DECODE_ERROR_CONCEALMENT_ACTIVE;
+}
+
static int finish_frame(AVCodecContext *avctx, AVFrame *pict)
{
RV34DecContext *r = avctx->priv_data;
MpegEncContext *s = &r->s;
int got_picture = 0, ret;
- ff_er_frame_end(&s->er);
+ rv34_er_frame_end(s);
ff_mpv_frame_end(s);
s->mb_num_left = 0;
@@ -1655,7 +1661,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict,
av_log(avctx, AV_LOG_ERROR, "New frame but still %d MB left.\n",
s->mb_num_left);
if (!s->context_reinit)
- ff_er_frame_end(&s->er);
+ rv34_er_frame_end(s);
ff_mpv_frame_end(s);
}
@@ -1790,7 +1796,7 @@ int ff_rv34_decode_frame(AVCodecContext *avctx, AVFrame *pict,
av_log(avctx, AV_LOG_INFO, "marking unfished frame as finished\n");
/* always mark the current frame as finished, frame-mt supports
* only complete frames */
- ff_er_frame_end(&s->er);
+ rv34_er_frame_end(s);
ff_mpv_frame_end(s);
s->mb_num_left = 0;
ff_thread_report_progress(&s->current_picture_ptr->tf, INT_MAX, 0);
diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c
index 9e343d003f..d930502176 100644
--- a/libavcodec/vc1dec.c
+++ b/libavcodec/vc1dec.c
@@ -1321,8 +1321,10 @@ static int vc1_decode_frame(AVCodecContext *avctx, AVFrame *pict,
}
if ( !v->field_mode
&& avctx->codec_id != AV_CODEC_ID_WMV3IMAGE
- && avctx->codec_id != AV_CODEC_ID_VC1IMAGE)
- ff_er_frame_end(&s->er);
+ && avctx->codec_id != AV_CODEC_ID_VC1IMAGE) {
+ if (ff_er_frame_end(&s->er) > 0)
+ s->current_picture.f->decode_error_flags |= FF_DECODE_ERROR_CONCEALMENT_ACTIVE;
+ }
}
ff_mpv_frame_end(s);
--
2.41.0
_______________________________________________
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] 13+ messages in thread
* [FFmpeg-devel] [PATCH 5/7] lavc/h264: export ecinfo
2023-07-21 13:37 [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata J. Dekker
` (2 preceding siblings ...)
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 4/7] lavc: set decode_error_flags when ec active J. Dekker
@ 2023-07-21 13:37 ` J. Dekker
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 6/7] tools/ffprobe: add ecinfo frame side data J. Dekker
` (4 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: J. Dekker @ 2023-07-21 13:37 UTC (permalink / raw)
To: ffmpeg-devel
Export ecinfo to the user when AV_CODEC_EXPORT_DATA_ERROR is set.
Co-Authored-By: Thomas Guillem <thomas@gllm.fr>
Signed-off-by: J. Dekker <jdek@itanimul.li>
---
libavcodec/h264_picture.c | 10 ++++++++--
libavcodec/h264_slice.c | 16 +++++++++++-----
libavcodec/h264dec.c | 33 +++++++++++++++++++++++++++------
libavcodec/h264dec.h | 8 +++++++-
4 files changed, 53 insertions(+), 14 deletions(-)
diff --git a/libavcodec/h264_picture.c b/libavcodec/h264_picture.c
index dcaf0fdb0a..aa7c5ac673 100644
--- a/libavcodec/h264_picture.c
+++ b/libavcodec/h264_picture.c
@@ -48,6 +48,7 @@ void ff_h264_unref_picture(H264Context *h, H264Picture *pic)
av_buffer_unref(&pic->qscale_table_buf);
av_buffer_unref(&pic->mb_type_buf);
av_buffer_unref(&pic->pps_buf);
+ av_buffer_unref(&pic->ec_info_buf);
for (i = 0; i < 2; i++) {
av_buffer_unref(&pic->motion_val_buf[i]);
av_buffer_unref(&pic->ref_index_buf[i]);
@@ -61,6 +62,7 @@ static void h264_copy_picture_params(H264Picture *dst, const H264Picture *src)
dst->qscale_table = src->qscale_table;
dst->mb_type = src->mb_type;
dst->pps = src->pps;
+ dst->ec_info = src->ec_info;
for (int i = 0; i < 2; i++) {
dst->motion_val[i] = src->motion_val[i];
@@ -111,7 +113,9 @@ int ff_h264_ref_picture(H264Context *h, H264Picture *dst, H264Picture *src)
dst->qscale_table_buf = av_buffer_ref(src->qscale_table_buf);
dst->mb_type_buf = av_buffer_ref(src->mb_type_buf);
dst->pps_buf = av_buffer_ref(src->pps_buf);
- if (!dst->qscale_table_buf || !dst->mb_type_buf || !dst->pps_buf) {
+ dst->ec_info_buf = av_buffer_ref(src->ec_info_buf);
+ if (!dst->qscale_table_buf || !dst->mb_type_buf || !dst->pps_buf
+ || !dst->ec_info_buf) {
ret = AVERROR(ENOMEM);
goto fail;
}
@@ -168,6 +172,7 @@ int ff_h264_replace_picture(H264Context *h, H264Picture *dst, const H264Picture
ret = av_buffer_replace(&dst->qscale_table_buf, src->qscale_table_buf);
ret |= av_buffer_replace(&dst->mb_type_buf, src->mb_type_buf);
ret |= av_buffer_replace(&dst->pps_buf, src->pps_buf);
+ ret |= av_buffer_replace(&dst->ec_info_buf, src->ec_info_buf);
if (ret < 0)
goto fail;
@@ -192,7 +197,7 @@ fail:
return ret;
}
-void ff_h264_set_erpic(ERPicture *dst, H264Picture *src)
+void ff_h264_set_erpic(ERPicture *dst, H264Picture *src, bool export_error)
{
#if CONFIG_ERROR_RESILIENCE
int i;
@@ -202,6 +207,7 @@ void ff_h264_set_erpic(ERPicture *dst, H264Picture *src)
if (!src)
return;
+ dst->info = export_error ? src->ec_info : NULL;
dst->f = src->f;
dst->tf = &src->tf;
diff --git a/libavcodec/h264_slice.c b/libavcodec/h264_slice.c
index 41bf30eefc..b291405c2a 100644
--- a/libavcodec/h264_slice.c
+++ b/libavcodec/h264_slice.c
@@ -176,12 +176,15 @@ static int init_table_pools(H264Context *h)
sizeof(int16_t), av_buffer_allocz);
h->ref_index_pool = av_buffer_pool_init(4 * mb_array_size, av_buffer_allocz);
+ h->ec_info_pool = av_buffer_pool_init(sizeof(AVECInfo), av_buffer_allocz);
+
if (!h->qscale_table_pool || !h->mb_type_pool || !h->motion_val_pool ||
- !h->ref_index_pool) {
+ !h->ref_index_pool || !h->ec_info_pool) {
av_buffer_pool_uninit(&h->qscale_table_pool);
av_buffer_pool_uninit(&h->mb_type_pool);
av_buffer_pool_uninit(&h->motion_val_pool);
av_buffer_pool_uninit(&h->ref_index_pool);
+ av_buffer_pool_uninit(&h->ec_info_pool);
return AVERROR(ENOMEM);
}
@@ -240,11 +243,13 @@ static int alloc_picture(H264Context *h, H264Picture *pic)
pic->qscale_table_buf = av_buffer_pool_get(h->qscale_table_pool);
pic->mb_type_buf = av_buffer_pool_get(h->mb_type_pool);
- if (!pic->qscale_table_buf || !pic->mb_type_buf)
+ pic->ec_info_buf = av_buffer_pool_get(h->ec_info_pool);
+ if (!pic->qscale_table_buf || !pic->mb_type_buf || !pic->ec_info_buf)
goto fail;
pic->mb_type = (uint32_t*)pic->mb_type_buf->data + 2 * h->mb_stride + 1;
pic->qscale_table = pic->qscale_table_buf->data + 2 * h->mb_stride + 1;
+ pic->ec_info = (AVECInfo*) pic->ec_info_buf->data;
for (i = 0; i < 2; i++) {
pic->motion_val_buf[i] = av_buffer_pool_get(h->motion_val_pool);
@@ -514,6 +519,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
pic->f->crop_right = h->crop_right;
pic->f->crop_top = h->crop_top;
pic->f->crop_bottom = h->crop_bottom;
+ pic->error_decode_slices = 0;
pic->needs_fg = h->sei.common.film_grain_characteristics.present && !h->avctx->hwaccel &&
!(h->avctx->export_side_data & AV_CODEC_EXPORT_DATA_FILM_GRAIN);
@@ -524,7 +530,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
h->cur_pic_ptr = pic;
ff_h264_unref_picture(h, &h->cur_pic);
if (CONFIG_ERROR_RESILIENCE) {
- ff_h264_set_erpic(&h->er.cur_pic, NULL);
+ ff_h264_set_erpic(&h->er.cur_pic, NULL, false);
}
if ((ret = ff_h264_ref_picture(h, &h->cur_pic, h->cur_pic_ptr)) < 0)
@@ -537,8 +543,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
if (CONFIG_ERROR_RESILIENCE && h->enable_er) {
ff_er_frame_start(&h->er);
- ff_h264_set_erpic(&h->er.last_pic, NULL);
- ff_h264_set_erpic(&h->er.next_pic, NULL);
+ ff_h264_set_erpic(&h->er.last_pic, NULL, false);
+ ff_h264_set_erpic(&h->er.next_pic, NULL, false);
}
for (i = 0; i < 16; i++) {
diff --git a/libavcodec/h264dec.c b/libavcodec/h264dec.c
index 19f8dba131..fa30f75f99 100644
--- a/libavcodec/h264dec.c
+++ b/libavcodec/h264dec.c
@@ -153,6 +153,7 @@ void ff_h264_free_tables(H264Context *h)
av_buffer_pool_uninit(&h->mb_type_pool);
av_buffer_pool_uninit(&h->motion_val_pool);
av_buffer_pool_uninit(&h->ref_index_pool);
+ av_buffer_pool_uninit(&h->ec_info_pool);
#if CONFIG_ERROR_RESILIENCE
av_freep(&h->er.mb_index2xy);
@@ -741,7 +742,7 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size)
// set decode_error_flags to allow users to detect concealed decoding errors
if ((ret < 0 || h->er.error_occurred) && h->cur_pic_ptr) {
- h->cur_pic_ptr->f->decode_error_flags |= FF_DECODE_ERROR_DECODE_SLICES;
+ h->cur_pic_ptr->error_decode_slices = 1;
}
ret = 0;
@@ -764,24 +765,34 @@ end:
H264SliceContext *sl = h->slice_ctx;
int use_last_pic = h->last_pic_for_ec.f->buf[0] && !sl->ref_count[0];
+ bool export_error = avctx->export_side_data & AV_CODEC_EXPORT_DATA_ERROR;
- ff_h264_set_erpic(&h->er.cur_pic, h->cur_pic_ptr);
+ ff_h264_set_erpic(&h->er.cur_pic, h->cur_pic_ptr, export_error);
if (use_last_pic) {
- ff_h264_set_erpic(&h->er.last_pic, &h->last_pic_for_ec);
+ ff_h264_set_erpic(&h->er.last_pic, &h->last_pic_for_ec, export_error);
sl->ref_list[0][0].parent = &h->last_pic_for_ec;
memcpy(sl->ref_list[0][0].data, h->last_pic_for_ec.f->data, sizeof(sl->ref_list[0][0].data));
memcpy(sl->ref_list[0][0].linesize, h->last_pic_for_ec.f->linesize, sizeof(sl->ref_list[0][0].linesize));
sl->ref_list[0][0].reference = h->last_pic_for_ec.reference;
} else if (sl->ref_count[0]) {
- ff_h264_set_erpic(&h->er.last_pic, sl->ref_list[0][0].parent);
+ ff_h264_set_erpic(&h->er.last_pic, sl->ref_list[0][0].parent, export_error);
} else
- ff_h264_set_erpic(&h->er.last_pic, NULL);
+ ff_h264_set_erpic(&h->er.last_pic, NULL, export_error);
if (sl->ref_count[1])
- ff_h264_set_erpic(&h->er.next_pic, sl->ref_list[1][0].parent);
+ ff_h264_set_erpic(&h->er.next_pic, sl->ref_list[1][0].parent, export_error);
ff_er_frame_end(&h->er);
+
+ /* Copy the ec_info into out_ec_info now since the ec_info might be
+ * written by an other thread while outputing the picture. Don't add
+ * the ec_info in the AVFrame side data since the AVFrame metadata
+ * can't be modified after calling ff_thread_finish_setup() (prevent
+ * data-races). */
+ if (export_error)
+ h->cur_pic_ptr->out_ec_info = *h->cur_pic_ptr->ec_info;
+
if (use_last_pic)
memset(&sl->ref_list[0][0], 0, sizeof(sl->ref_list[0][0]));
}
@@ -850,6 +861,16 @@ static int output_frame(H264Context *h, AVFrame *dst, H264Picture *srcp)
if (ret < 0)
return ret;
+ if (srcp->out_ec_info.error | srcp->out_ec_info.ref_error) {
+ AVECInfo *eci = av_eci_create_side_data(dst);
+ if (eci)
+ *eci = srcp->out_ec_info;
+ dst->decode_error_flags |= FF_DECODE_ERROR_CONCEALMENT_ACTIVE;
+ av_log(h, AV_LOG_DEBUG, "ecinfo error: %" PRIu64 ", ref_error: %" PRIu64 "\n", eci->error, eci->ref_error);
+ }
+ if (srcp->error_decode_slices)
+ dst->decode_error_flags |= FF_DECODE_ERROR_DECODE_SLICES;
+
if (srcp->needs_fg && (ret = av_frame_copy_props(dst, srcp->f)) < 0)
return ret;
diff --git a/libavcodec/h264dec.h b/libavcodec/h264dec.h
index 9a1ec1bace..5a541e2c0b 100644
--- a/libavcodec/h264dec.h
+++ b/libavcodec/h264dec.h
@@ -154,6 +154,11 @@ typedef struct H264Picture {
int mb_width, mb_height;
int mb_stride;
+
+ AVBufferRef *ec_info_buf;
+ AVECInfo *ec_info;
+ AVECInfo out_ec_info;
+ int error_decode_slices;
} H264Picture;
typedef struct H264Ref {
@@ -551,6 +556,7 @@ typedef struct H264Context {
AVBufferPool *mb_type_pool;
AVBufferPool *motion_val_pool;
AVBufferPool *ref_index_pool;
+ AVBufferPool *ec_info_pool;
int ref2frm[MAX_SLICES][2][64]; ///< reference to frame number lists, used in the loop filter, the first 2 are for -2,-1
} H264Context;
@@ -806,6 +812,6 @@ void ff_h264_flush_change(H264Context *h);
void ff_h264_free_tables(H264Context *h);
-void ff_h264_set_erpic(ERPicture *dst, H264Picture *src);
+void ff_h264_set_erpic(ERPicture *dst, H264Picture *src, bool export_error);
#endif /* AVCODEC_H264DEC_H */
--
2.41.0
_______________________________________________
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] 13+ messages in thread
* [FFmpeg-devel] [PATCH 6/7] tools/ffprobe: add ecinfo frame side data
2023-07-21 13:37 [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata J. Dekker
` (3 preceding siblings ...)
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 5/7] lavc/h264: export ecinfo J. Dekker
@ 2023-07-21 13:37 ` J. Dekker
2023-07-21 13:47 ` [FFmpeg-devel] [PATCH 6/7 v1.1] " J. Dekker
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 7/7] fate: add ecinfo sidedata test J. Dekker
` (3 subsequent siblings)
8 siblings, 1 reply; 13+ messages in thread
From: J. Dekker @ 2023-07-21 13:37 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: J. Dekker <jdek@itanimul.li>
---
fftools/ffprobe.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index a39185f6fe..9b1f04e1be 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -39,6 +39,7 @@
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/display.h"
+#include "libavutil/ec.h"
#include "libavutil/hash.h"
#include "libavutil/hdr_dynamic_metadata.h"
#include "libavutil/mastering_display_metadata.h"
@@ -2277,6 +2278,17 @@ static void print_ambient_viewing_environment(WriterContext *w,
print_q("ambient_light_y", env->ambient_light_y, '/');
}
+static void print_ecinfo(WriterContext *w, const AVECInfo *ecinfo)
+{
+ if (!ecinfo)
+ return;
+
+ print_int("ok", ecinfo->ok);
+ print_int("error", ecinfo->error);
+ print_int("ref_ok", ecinfo->ref_ok);
+ print_int("ref_error", ecinfo->ref_error);
+}
+
static void print_pkt_side_data(WriterContext *w,
AVCodecParameters *par,
const AVPacketSideData *side_data,
@@ -2741,6 +2753,8 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
} else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
print_ambient_viewing_environment(
w, (const AVAmbientViewingEnvironment *)sd->data);
+ } else if (sd->type = AV_FRAME_DATA_EC_INFO) {
+ print_ecinfo(w, (AVECInfo*)sd->data);
}
writer_print_section_footer(w);
}
--
2.41.0
_______________________________________________
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] 13+ messages in thread
* [FFmpeg-devel] [PATCH 6/7 v1.1] tools/ffprobe: add ecinfo frame side data
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 6/7] tools/ffprobe: add ecinfo frame side data J. Dekker
@ 2023-07-21 13:47 ` J. Dekker
0 siblings, 0 replies; 13+ messages in thread
From: J. Dekker @ 2023-07-21 13:47 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: J. Dekker <jdek@itanimul.li>
---
fftools/ffprobe.c | 14 ++++++++++++++
1 file changed, 14 insertions(+)
diff --git a/fftools/ffprobe.c b/fftools/ffprobe.c
index a39185f6fe..572a5150cf 100644
--- a/fftools/ffprobe.c
+++ b/fftools/ffprobe.c
@@ -39,6 +39,7 @@
#include "libavutil/bprint.h"
#include "libavutil/channel_layout.h"
#include "libavutil/display.h"
+#include "libavutil/ec.h"
#include "libavutil/hash.h"
#include "libavutil/hdr_dynamic_metadata.h"
#include "libavutil/mastering_display_metadata.h"
@@ -2277,6 +2278,17 @@ static void print_ambient_viewing_environment(WriterContext *w,
print_q("ambient_light_y", env->ambient_light_y, '/');
}
+static void print_ecinfo(WriterContext *w, const AVECInfo *ecinfo)
+{
+ if (!ecinfo)
+ return;
+
+ print_int("ok", ecinfo->ok);
+ print_int("error", ecinfo->error);
+ print_int("ref_ok", ecinfo->ref_ok);
+ print_int("ref_error", ecinfo->ref_error);
+}
+
static void print_pkt_side_data(WriterContext *w,
AVCodecParameters *par,
const AVPacketSideData *side_data,
@@ -2741,6 +2753,8 @@ static void show_frame(WriterContext *w, AVFrame *frame, AVStream *stream,
} else if (sd->type == AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT) {
print_ambient_viewing_environment(
w, (const AVAmbientViewingEnvironment *)sd->data);
+ } else if (sd->type == AV_FRAME_DATA_EC_INFO) {
+ print_ecinfo(w, (AVECInfo*)sd->data);
}
writer_print_section_footer(w);
}
--
2.41.0
_______________________________________________
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] 13+ messages in thread
* [FFmpeg-devel] [PATCH 7/7] fate: add ecinfo sidedata test
2023-07-21 13:37 [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata J. Dekker
` (4 preceding siblings ...)
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 6/7] tools/ffprobe: add ecinfo frame side data J. Dekker
@ 2023-07-21 13:37 ` J. Dekker
2023-07-21 14:44 ` [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata Devin Heitmueller
` (2 subsequent siblings)
8 siblings, 0 replies; 13+ messages in thread
From: J. Dekker @ 2023-07-21 13:37 UTC (permalink / raw)
To: ffmpeg-devel
Signed-off-by: J. Dekker <jdek@itanimul.li>
---
tests/Makefile | 1 +
tests/fate/ec.mak | 6 +
tests/ref/fate/ec-sidedata-h264 | 332 ++++++++++++++++++++++++++++++++
3 files changed, 339 insertions(+)
create mode 100644 tests/fate/ec.mak
create mode 100644 tests/ref/fate/ec-sidedata-h264
ec/basic.h264 is available here: https://0x1.st/bP.h264
diff --git a/tests/Makefile b/tests/Makefile
index e09f30a0fc..f108a2460b 100644
--- a/tests/Makefile
+++ b/tests/Makefile
@@ -176,6 +176,7 @@ include $(SRC_PATH)/tests/fate/dnxhd.mak
include $(SRC_PATH)/tests/fate/dpcm.mak
include $(SRC_PATH)/tests/fate/dvvideo.mak
include $(SRC_PATH)/tests/fate/ea.mak
+include $(SRC_PATH)/tests/fate/ec.mak
include $(SRC_PATH)/tests/fate/exif.mak
include $(SRC_PATH)/tests/fate/enc_external.mak
# Must be included after lavf-video.mak
diff --git a/tests/fate/ec.mak b/tests/fate/ec.mak
new file mode 100644
index 0000000000..fe46b7f8f8
--- /dev/null
+++ b/tests/fate/ec.mak
@@ -0,0 +1,6 @@
+FATE_EC-$(call ALLYES, ERROR_RESILIENCE H264_PARSER H264_DECODER) += fate-ec-sidedata-h264
+fate-ec-sidedata-h264: SRC = $(TARGET_SAMPLES)/ec/basic.h264
+fate-ec-sidedata-h264: CMD = run ffprobe$(PROGSSUF)$(EXESUF) -export_side_data +error_info -show_entries side_data -print_format default -bitexact -v 0 -i "$(SRC)"
+
+FATE_SAMPLES_FFMPEG+=$(FATE_EC-yes)
+fate-ec: $(FATE_EC-yes)
diff --git a/tests/ref/fate/ec-sidedata-h264 b/tests/ref/fate/ec-sidedata-h264
new file mode 100644
index 0000000000..e00d2fc89c
--- /dev/null
+++ b/tests/ref/fate/ec-sidedata-h264
@@ -0,0 +1,332 @@
+[PACKET]
+[/PACKET]
+[PACKET]
+[/PACKET]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=414720
+error=142336
+ref_ok=0
+ref_error=0
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=414720
+ref_error=142336
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=414720
+ref_error=142336
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=414720
+ref_error=142336
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=414720
+ref_error=142336
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=414720
+ref_error=142336
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=414720
+ref_error=142336
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=414720
+ref_error=142336
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=414720
+ref_error=142336
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=1007360
+ref_error=663808
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=290816
+error=266240
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=1007360
+ref_error=663808
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=301824
+error=255232
+ref_ok=414720
+ref_error=142336
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[PACKET]
+[/PACKET]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[FRAME]
+[SIDE_DATA]
+side_data_type=Error Concealment Information
+ok=0
+error=0
+ref_ok=716544
+ref_error=397568
+[/SIDE_DATA]
+[/FRAME]
+[STREAM]
+[/STREAM]
--
2.41.0
_______________________________________________
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] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata
2023-07-21 13:37 [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata J. Dekker
` (5 preceding siblings ...)
2023-07-21 13:37 ` [FFmpeg-devel] [PATCH 7/7] fate: add ecinfo sidedata test J. Dekker
@ 2023-07-21 14:44 ` Devin Heitmueller
2023-07-25 12:05 ` J. Dekker
2023-07-21 23:49 ` Michael Niedermayer
[not found] ` <20230721133746.33335-1-jdek@itanimul.li-N_sf260--B-9>
8 siblings, 1 reply; 13+ messages in thread
From: Devin Heitmueller @ 2023-07-21 14:44 UTC (permalink / raw)
To: FFmpeg development discussions and patches
On Fri, Jul 21, 2023 at 9:38 AM J. Dekker <jdek@itanimul.li> wrote:
>
> Add sidedata for passing basic Error Concealment information helpful to
> a renderer or end user attempting to filter or conceal video decoding
> errors and artifacts.
>
> Co-Authored-By: Thomas Guillem <thomas@gllm.fr>
> Signed-off-by: J. Dekker <jdek@itanimul.li>
> ---
> libavutil/Makefile | 2 ++
> libavutil/ec.c | 42 +++++++++++++++++++++++++++++
> libavutil/ec.h | 66 +++++++++++++++++++++++++++++++++++++++++++++
> libavutil/frame.c | 1 +
> libavutil/frame.h | 6 +++++
> libavutil/version.h | 2 +-
> 6 files changed, 118 insertions(+), 1 deletion(-)
> create mode 100644 libavutil/ec.c
> create mode 100644 libavutil/ec.h
>
> diff --git a/libavutil/Makefile b/libavutil/Makefile
> index bd9c6f9e32..81b6b1fb8a 100644
> --- a/libavutil/Makefile
> +++ b/libavutil/Makefile
> @@ -28,6 +28,7 @@ HEADERS = adler32.h \
> display.h \
> dovi_meta.h \
> downmix_info.h \
> + ec.h \
> encryption_info.h \
> error.h \
> eval.h \
> @@ -124,6 +125,7 @@ OBJS = adler32.o \
> dovi_meta.o \
> downmix_info.o \
> encryption_info.o \
> + ec.o \
> error.o \
> eval.o \
> fifo.o \
> diff --git a/libavutil/ec.c b/libavutil/ec.c
> new file mode 100644
> index 0000000000..762accd0a6
> --- /dev/null
> +++ b/libavutil/ec.c
> @@ -0,0 +1,42 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#include "config.h"
> +#include "ec.h"
> +
> +AVECInfo *av_eci_create_side_data(AVFrame *f)
> +{
> + AVBufferRef *buf = NULL;
> + AVECInfo *eci = av_mallocz(sizeof(AVECInfo));
> +
> + if (!eci)
> + return NULL;
> +
> + buf = av_buffer_create((uint8_t *)eci, sizeof(AVECInfo), NULL, NULL, 0);
> + if (!buf) {
> + av_freep(&eci);
> + return NULL;
> + }
> +
> + if (!av_frame_new_side_data_from_buf(f, AV_FRAME_DATA_EC_INFO, buf)) {
> + av_buffer_unref(&buf);
> + return NULL;
> + }
> +
> + return eci;
> +}
> diff --git a/libavutil/ec.h b/libavutil/ec.h
> new file mode 100644
> index 0000000000..439fe876a2
> --- /dev/null
> +++ b/libavutil/ec.h
> @@ -0,0 +1,66 @@
> +/*
> + * This file is part of FFmpeg.
> + *
> + * FFmpeg is free software; you can redistribute it and/or
> + * modify it under the terms of the GNU Lesser General Public
> + * License as published by the Free Software Foundation; either
> + * version 2.1 of the License, or (at your option) any later version.
> + *
> + * FFmpeg is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
> + * Lesser General Public License for more details.
> + *
> + * You should have received a copy of the GNU Lesser General Public
> + * License along with FFmpeg; if not, write to the Free Software
> + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
> + */
> +
> +#ifndef AVUTIL_EC_H
> +#define AVUTIL_EC_H
> +
> +#include <stdbool.h>
> +#include <stddef.h>
> +#include <stdint.h>
> +
> +#include "libavutil/mem.h"
> +#include "libavutil/frame.h"
> +
> +/**
> + * Error Concealment information helpful to a renderer or end user
> + * attempting to filter or conceal video decoding errors and artifacts.
> + */
> +typedef struct AVECInfo {
> + /**
> + * Integer estimating how many pixels of the video frame had decoding
> + * errors.
> + */
> + uint64_t error;
> + /**
> + * Integer estimating how many pixels of the video frame decoded
> + * without error.
> + */
> + uint64_t ok;
> + /**
> + * Integer estimating how many pixels of the video frame's reference
> + * frames had decoding errors.
> + */
> + uint64_t ref_error;
> + /**
> + * Integer estimating how many pixels of the video frame's reference
> + * frames decoded without error.
> + */
> + uint64_t ref_ok;
> +} AVECInfo;
> +
> +static inline void av_eci_reset(AVECInfo *info)
> +{
> + info->error = info->ok = info->ref_error = info->ref_ok = 0;
> +}
> +
> +/**
> + * Creates AVECInfo in a specified frame as side data.
> + */
> +AVECInfo *av_eci_create_side_data(AVFrame *f);
> +
> +#endif /* AVUTIL_EC_H */
> diff --git a/libavutil/frame.c b/libavutil/frame.c
> index b6cee2d886..30a838bf22 100644
> --- a/libavutil/frame.c
> +++ b/libavutil/frame.c
> @@ -960,6 +960,7 @@ const char *av_frame_side_data_name(enum AVFrameSideDataType type)
> case AV_FRAME_DATA_DOVI_RPU_BUFFER: return "Dolby Vision RPU Data";
> case AV_FRAME_DATA_DOVI_METADATA: return "Dolby Vision Metadata";
> case AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT: return "Ambient viewing environment";
> + case AV_FRAME_DATA_EC_INFO: return "Error Concealment Information";
> }
> return NULL;
> }
> diff --git a/libavutil/frame.h b/libavutil/frame.h
> index a491315f25..08c6b96d29 100644
> --- a/libavutil/frame.h
> +++ b/libavutil/frame.h
> @@ -214,6 +214,12 @@ enum AVFrameSideDataType {
> * Ambient viewing environment metadata, as defined by H.274.
> */
> AV_FRAME_DATA_AMBIENT_VIEWING_ENVIRONMENT,
> + /**
> + * Error Concealment Information helpful to a renderer attempting to filter
> + * or conceal video decoding errors and artifacts. See AVECInfo defined in
> + * libavutil/error.h.
> + */
> + AV_FRAME_DATA_EC_INFO,
> };
>
> enum AVActiveFormatDescription {
> diff --git a/libavutil/version.h b/libavutil/version.h
> index 24af520e08..9e798b0e3f 100644
> --- a/libavutil/version.h
> +++ b/libavutil/version.h
> @@ -79,7 +79,7 @@
> */
>
> #define LIBAVUTIL_VERSION_MAJOR 58
> -#define LIBAVUTIL_VERSION_MINOR 14
> +#define LIBAVUTIL_VERSION_MINOR 15
> #define LIBAVUTIL_VERSION_MICRO 100
>
> #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \
> --
> 2.41.0
>
> _______________________________________________
> 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".
Hi J,
I appreciate the value of stats so I can tell that the stream had
errors, but how is this side data "helpful to a renderer attempting to
filter or conceal video decoding errors and artifacts" if there is no
information relating to the region of the picture where the errors are
present? Is the assumption that an application will simply have some
threshold at which it decides to duplicate the previous frame rather
than showing the current one?
Thanks,
Devin
--
Devin Heitmueller, Senior Software Engineer
LTN Global Communications
o: +1 (301) 363-1001
w: https://ltnglobal.com e: devin.heitmueller@ltnglobal.com
_______________________________________________
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] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata
2023-07-21 14:44 ` [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata Devin Heitmueller
@ 2023-07-25 12:05 ` J. Dekker
2023-07-25 22:00 ` Michael Niedermayer
0 siblings, 1 reply; 13+ messages in thread
From: J. Dekker @ 2023-07-25 12:05 UTC (permalink / raw)
To: ffmpeg-devel
Hi Devin,
Devin Heitmueller <devin.heitmueller@ltnglobal.com> writes:
> On Fri, Jul 21, 2023 at 9:38 AM J. Dekker <jdek@itanimul.li> wrote:
>
> I appreciate the value of stats so I can tell that the stream had
> errors, but how is this side data "helpful to a renderer attempting to
> filter or conceal video decoding errors and artifacts" if there is no
> information relating to the region of the picture where the errors are
> present? Is the assumption that an application will simply have some
> threshold at which it decides to duplicate the previous frame rather
> than showing the current one?
Yes, this is primarily the usecase here initially. As some point a
renderer would rather duplicate previous frame than rely on
reconstruction. This could be done within EC itself but letting the
decoder make this choice rather than exporting the information to a
renderer and doing it there seems incorrect to me.
It is the intention to expand the metadata to provide information about
specific regions in the frame in the future but mainly just providing
the framework for providing this sort of information in the first place
at the moment.
--
jd
_______________________________________________
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] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata
2023-07-25 12:05 ` J. Dekker
@ 2023-07-25 22:00 ` Michael Niedermayer
0 siblings, 0 replies; 13+ messages in thread
From: Michael Niedermayer @ 2023-07-25 22:00 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 2590 bytes --]
On Tue, Jul 25, 2023 at 02:05:43PM +0200, J. Dekker wrote:
>
> Hi Devin,
>
> Devin Heitmueller <devin.heitmueller@ltnglobal.com> writes:
> > On Fri, Jul 21, 2023 at 9:38 AM J. Dekker <jdek@itanimul.li> wrote:
> >
> > I appreciate the value of stats so I can tell that the stream had
> > errors, but how is this side data "helpful to a renderer attempting to
> > filter or conceal video decoding errors and artifacts" if there is no
> > information relating to the region of the picture where the errors are
> > present? Is the assumption that an application will simply have some
> > threshold at which it decides to duplicate the previous frame rather
> > than showing the current one?
>
> Yes, this is primarily the usecase here initially. As some point a
> renderer would rather duplicate previous frame than rely on
> reconstruction. This could be done within EC itself but letting the
> decoder make this choice rather than exporting the information to a
> renderer and doing it there seems incorrect to me.
Error concealment is not merely a choice of copying or not
Some areas may be damaged, surrounding areas may be undamaged
an example could be a row of macroblocks / a slice
To perform error concealment properly you need to know the motion
vectors of the surrounding slices and their macroblock types
for example if all the surrounding macroblocks have a motion vector
pointing left by 7 pixels the lost slice likely needs to be
using the same.
This requires also knowledge of the reference frames the decoder used
and ability to apply similar motion compensation to know what "-7" means
If there are different motion vecstors used in surrounding macroblocks
it becomes even more complex
Also with some decoders you can loose the texture of a slice but have
undamaged motion vectors. Or you may have intra slices with DC undamaged
but AC lost for every macroblock
And if its all intra blocks, some inpainting based on spatial surroundings
may be better than using the previosu frames.
This is all implemented in our error concealment code.
Trying to do this outside is a mistake. Not only is it hard due to the
deep connection to decoder state it is also something every user of
libavcodec needs. The code belongs in a place every libavcodec user
has access to and can reuse it from.
Thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
If a bugfix only changes things apparently unrelated to the bug with no
further explanation, that is a good sign that the bugfix is wrong.
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 13+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata
2023-07-21 13:37 [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata J. Dekker
` (6 preceding siblings ...)
2023-07-21 14:44 ` [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata Devin Heitmueller
@ 2023-07-21 23:49 ` Michael Niedermayer
[not found] ` <20230721133746.33335-1-jdek@itanimul.li-N_sf260--B-9>
8 siblings, 0 replies; 13+ messages in thread
From: Michael Niedermayer @ 2023-07-21 23:49 UTC (permalink / raw)
To: FFmpeg development discussions and patches
[-- Attachment #1.1: Type: text/plain, Size: 812 bytes --]
On Fri, Jul 21, 2023 at 03:37:40PM +0200, J. Dekker wrote:
> Add sidedata for passing basic Error Concealment information helpful to
> a renderer or end user attempting to filter or conceal video decoding
> errors and artifacts.
The exported information seems too basic to perform error concealment with it.
Also we have error_concealment code that does much better than what could be
done from outside easily, that should be used.
The commit message leaves a lot of "why", "for what", "how" questions
Its not clear to me what this patchset is really trying to achieve
thx
[...]
--
Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB
When you are offended at any man's fault, turn to yourself and study your
own failings. Then you will forget your anger. -- Epictetus
[-- Attachment #1.2: signature.asc --]
[-- Type: application/pgp-signature, Size: 195 bytes --]
[-- Attachment #2: Type: text/plain, Size: 251 bytes --]
_______________________________________________
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] 13+ messages in thread
[parent not found: <20230721133746.33335-1-jdek@itanimul.li-N_sf260--B-9>]
* Re: [FFmpeg-devel] [PATCH 1/7] lavu: add ecinfo sidedata
[not found] ` <20230721133746.33335-1-jdek@itanimul.li-N_sf260--B-9>
@ 2023-07-22 0:12 ` Lynne
0 siblings, 0 replies; 13+ messages in thread
From: Lynne @ 2023-07-22 0:12 UTC (permalink / raw)
To: FFmpeg development discussions and patches
Jul 21, 2023, 15:38 by jdek@itanimul.li:
> Add sidedata for passing basic Error Concealment information helpful to
> a renderer or end user attempting to filter or conceal video decoding
> errors and artifacts.
>
> Co-Authored-By: Thomas Guillem <thomas@gllm.fr>
> Signed-off-by: J. Dekker <jdek@itanimul.li>
> ---
> libavutil/Makefile | 2 ++
> libavutil/ec.c | 42 +++++++++++++++++++++++++++++
> libavutil/ec.h | 66 +++++++++++++++++++++++++++++++++++++++++++++
> libavutil/frame.c | 1 +
> libavutil/frame.h | 6 +++++
> libavutil/version.h | 2 +-
> 6 files changed, 118 insertions(+), 1 deletion(-)
> create mode 100644 libavutil/ec.c
> create mode 100644 libavutil/ec.h
>
Maybe using the same data structures as the new proposed hint
video hint data (currently only used for damage) would save needing
another side data type?
_______________________________________________
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] 13+ messages in thread