[FFmpeg-cvslog] avcodec/smcenc: fix errors with using intra after inter skip

2022-12-02 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Fri Dec  2 19:02:24 
2022 +0100| [fb51eebc6cb3df8e6ee232a650fbb4c1a05c4125] | committer: Paul B Mahol

avcodec/smcenc: fix errors with using intra after inter skip

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fb51eebc6cb3df8e6ee232a650fbb4c1a05c4125
---

 libavcodec/smcenc.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/libavcodec/smcenc.c b/libavcodec/smcenc.c
index 9ff9dc697d..33f9dfcc24 100644
--- a/libavcodec/smcenc.c
+++ b/libavcodec/smcenc.c
@@ -127,6 +127,7 @@ static void smc_encode_stream(SMCContext *s, const AVFrame 
*frame,
 int color_pair_index = 0;
 int color_quad_index = 0;
 int color_octet_index = 0;
+int prev_block_inter = 0;
 int color_table_index;  /* indexes to color pair, quad, or octet tables */
 int total_blocks;
 int cur_y = 0;
@@ -182,10 +183,10 @@ static void smc_encode_stream(SMCContext *s, const 
AVFrame *frame,
 cur_y = frame_y;
 cur_x = frame_x;
 
-while (block_counter > 0 && block_counter + intra_skip_blocks < 
total_blocks) {
+while (block_counter > 0 && prev_block_inter == 0 && block_counter + 
intra_skip_blocks < total_blocks) {
 const int y_size = FFMIN(4, height - cur_y);
 const int x_size = FFMIN(4, width  - cur_x);
-const ptrdiff_t offset = pixel_ptr - src_pixels;
+const ptrdiff_t offset = xpixel_ptr - src_pixels;
 const int sy = offset / stride;
 const int sx = offset % stride;
 const int ny = sx < 4 ? sy - 4 : sy;
@@ -194,7 +195,7 @@ static void smc_encode_stream(SMCContext *s, const AVFrame 
*frame,
 int compare = 0;
 
 for (int y = 0; y < y_size; y++) {
-compare |= memcmp(old_pixel_ptr + y * stride, pixel_ptr + y * 
stride, x_size);
+compare |= !!memcmp(old_pixel_ptr + y * stride, pixel_ptr + y 
* stride, x_size);
 if (compare)
 break;
 }
@@ -271,6 +272,7 @@ static void smc_encode_stream(SMCContext *s, const AVFrame 
*frame,
 blocks = inter_skip_blocks;
 }
 
+prev_block_inter = distinct == 19 || distinct == 20;
 switch (distinct) {
 case 1:
 if (blocks <= 16) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/smcenc: improve compression ratio a little

2022-12-02 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Fri Dec  2 21:17:34 
2022 +0100| [8d9f7fa79ecc194dc1e7148b824eea6d779ee918] | committer: Paul B Mahol

avcodec/smcenc: improve compression ratio a little

Actually reverts previous change.

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=8d9f7fa79ecc194dc1e7148b824eea6d779ee918
---

 libavcodec/smcenc.c | 25 +
 1 file changed, 13 insertions(+), 12 deletions(-)

diff --git a/libavcodec/smcenc.c b/libavcodec/smcenc.c
index 33f9dfcc24..e3ea7e5e9f 100644
--- a/libavcodec/smcenc.c
+++ b/libavcodec/smcenc.c
@@ -127,16 +127,11 @@ static void smc_encode_stream(SMCContext *s, const 
AVFrame *frame,
 int color_pair_index = 0;
 int color_quad_index = 0;
 int color_octet_index = 0;
-int prev_block_inter = 0;
 int color_table_index;  /* indexes to color pair, quad, or octet tables */
 int total_blocks;
 int cur_y = 0;
 int cur_x = 0;
 
-memset(s->color_pairs, 0, sizeof(s->color_pairs));
-memset(s->color_quads, 0, sizeof(s->color_quads));
-memset(s->color_octets, 0, sizeof(s->color_octets));
-
 /* Number of 4x4 blocks in frame. */
 total_blocks = ((width + 3) / 4) * ((height + 3) / 4);
 
@@ -183,7 +178,7 @@ static void smc_encode_stream(SMCContext *s, const AVFrame 
*frame,
 cur_y = frame_y;
 cur_x = frame_x;
 
-while (block_counter > 0 && prev_block_inter == 0 && block_counter + 
intra_skip_blocks < total_blocks) {
+while (block_counter > 0 && block_counter + intra_skip_blocks < 
total_blocks) {
 const int y_size = FFMIN(4, height - cur_y);
 const int x_size = FFMIN(4, width  - cur_x);
 const ptrdiff_t offset = xpixel_ptr - src_pixels;
@@ -249,30 +244,36 @@ static void smc_encode_stream(SMCContext *s, const 
AVFrame *frame,
 cur_y = frame_y;
 cur_x = frame_x;
 
-blocks = coded_blocks;
+blocks = coded_distinct <= 8 ? coded_blocks : 0;
 distinct = coded_distinct;
 
-if (intra_skip_blocks > 0 && intra_skip_blocks >= inter_skip_blocks) {
+if (intra_skip_blocks >= blocks && intra_skip_blocks >= 
inter_skip_blocks) {
 distinct = 17;
 blocks = intra_skip_blocks;
 }
 
-if (intra_skip_blocks > 16 && intra_skip_blocks >= inter_skip_blocks) {
+if (intra_skip_blocks > 16 && intra_skip_blocks >= inter_skip_blocks &&
+intra_skip_blocks >= blocks) {
 distinct = 18;
 blocks = intra_skip_blocks;
 }
 
-if (inter_skip_blocks > 0 && inter_skip_blocks > intra_skip_blocks) {
+if (inter_skip_blocks >= blocks && inter_skip_blocks > 
intra_skip_blocks) {
 distinct = 19;
 blocks = inter_skip_blocks;
 }
 
-if (inter_skip_blocks > 16 && inter_skip_blocks > intra_skip_blocks) {
+if (inter_skip_blocks > 16 && inter_skip_blocks > intra_skip_blocks &&
+inter_skip_blocks >= blocks) {
 distinct = 20;
 blocks = inter_skip_blocks;
 }
 
-prev_block_inter = distinct == 19 || distinct == 20;
+if (blocks == 0) {
+blocks = coded_blocks;
+distinct = coded_distinct;
+}
+
 switch (distinct) {
 case 1:
 if (blocks <= 16) {

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".


[FFmpeg-cvslog] avcodec/libsvtav1: don't force a default value for deprecated options

2022-12-02 Thread James Almer
ffmpeg | branch: master | James Almer  | Tue Nov 29 18:35:27 
2022 -0300| [fe196fd29a6769e456b31aa43983e64e5b7c60d6] | committer: James Almer

avcodec/libsvtav1: don't force a default value for deprecated options

Stick to the library's default value instead.

Should address AOMediaCodec/SVT-AV1 issue #2011.

Signed-off-by: James Almer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=fe196fd29a6769e456b31aa43983e64e5b7c60d6
---

 libavcodec/libsvtav1.c | 27 ---
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/libavcodec/libsvtav1.c b/libavcodec/libsvtav1.c
index 7605baddfe..56e1e22b51 100644
--- a/libavcodec/libsvtav1.c
+++ b/libavcodec/libsvtav1.c
@@ -155,14 +155,19 @@ static int config_enc_params(EbSvtAv1EncConfiguration 
*param,
 
 // Update param from options
 #if FF_API_SVTAV1_OPTS
-param->hierarchical_levels  = svt_enc->hierarchical_level;
-param->tier = svt_enc->tier;
-param->scene_change_detection   = svt_enc->scd;
-param->tile_columns = svt_enc->tile_columns;
-param->tile_rows= svt_enc->tile_rows;
+if (svt_enc->hierarchical_level >= 0)
+param->hierarchical_levels= svt_enc->hierarchical_level;
+if (svt_enc->tier >= 0)
+param->tier   = svt_enc->tier;
+if (svt_enc->scd >= 0)
+param->scene_change_detection = svt_enc->scd;
+if (svt_enc->tile_columns >= 0)
+param->tile_columns   = svt_enc->tile_columns;
+if (svt_enc->tile_rows >= 0)
+param->tile_rows  = svt_enc->tile_rows;
 
 if (svt_enc->la_depth >= 0)
-param->look_ahead_distance  = svt_enc->la_depth;
+param->look_ahead_distance= svt_enc->la_depth;
 #endif
 
 if (svt_enc->enc_mode >= 0)
@@ -572,7 +577,7 @@ static av_cold int eb_enc_close(AVCodecContext *avctx)
 static const AVOption options[] = {
 #if FF_API_SVTAV1_OPTS
 { "hielevel", "Hierarchical prediction levels setting (Deprecated, use 
svtav1-params)", OFFSET(hierarchical_level),
-  AV_OPT_TYPE_INT, { .i64 = 4 }, 3, 4, VE | AV_OPT_FLAG_DEPRECATED , 
"hielevel"},
+  AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 4, VE | AV_OPT_FLAG_DEPRECATED , 
"hielevel"},
 { "3level", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 3 },  INT_MIN, 
INT_MAX, VE, "hielevel" },
 { "4level", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 4 },  INT_MIN, 
INT_MAX, VE, "hielevel" },
 
@@ -580,7 +585,7 @@ static const AVOption options[] = {
   AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 120, VE | AV_OPT_FLAG_DEPRECATED },
 
 { "tier", "Set operating point tier (Deprecated, use svtav1-params)", 
OFFSET(tier),
-  AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 1, VE | AV_OPT_FLAG_DEPRECATED, "tier" 
},
+  AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 1, VE | AV_OPT_FLAG_DEPRECATED, 
"tier" },
 { "main", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 0 }, 0, 0, VE, "tier" },
 { "high", NULL, 0, AV_OPT_TYPE_CONST, { .i64 = 1 }, 0, 0, VE, "tier" },
 #endif
@@ -623,10 +628,10 @@ static const AVOption options[] = {
   AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 63, VE },
 #if FF_API_SVTAV1_OPTS
 { "sc_detection", "Scene change detection (Deprecated, use 
svtav1-params)", OFFSET(scd),
-  AV_OPT_TYPE_BOOL, { .i64 = 0 }, 0, 1, VE | AV_OPT_FLAG_DEPRECATED },
+  AV_OPT_TYPE_BOOL, { .i64 = -1 }, -1, 1, VE | AV_OPT_FLAG_DEPRECATED },
 
-{ "tile_columns", "Log2 of number of tile columns to use (Deprecated, use 
svtav1-params)", OFFSET(tile_columns), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 4, VE 
| AV_OPT_FLAG_DEPRECATED },
-{ "tile_rows", "Log2 of number of tile rows to use (Deprecated, use 
svtav1-params)", OFFSET(tile_rows), AV_OPT_TYPE_INT, { .i64 = 0 }, 0, 6, VE | 
AV_OPT_FLAG_DEPRECATED },
+{ "tile_columns", "Log2 of number of tile columns to use (Deprecated, use 
svtav1-params)", OFFSET(tile_columns), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 4, 
VE | AV_OPT_FLAG_DEPRECATED },
+{ "tile_rows", "Log2 of number of tile rows to use (Deprecated, use 
svtav1-params)", OFFSET(tile_rows), AV_OPT_TYPE_INT, { .i64 = -1 }, -1, 6, VE | 
AV_OPT_FLAG_DEPRECATED },
 #endif
 
 { "svtav1-params", "Set the SVT-AV1 configuration using a :-separated list 
of key=value parameters", OFFSET(svtav1_opts), AV_OPT_TYPE_DICT, { 0 }, 0, 0, 
VE },

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
https://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog

To unsubscribe, visit link above, or email
ffmpeg-cvslog-requ...@ffmpeg.org with subject "unsubscribe".