* [FFmpeg-devel] [PATCH 1/5] avcodec/clearvideo: Remove unnecessary level parameter
@ 2022-11-07 1:48 Andreas Rheinhardt
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 2/5] avcodec/clearvideo: Move tile_do_block() upwards Andreas Rheinhardt
` (4 more replies)
0 siblings, 5 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2022-11-07 1:48 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/clearvideo.c | 23 +++++++++++------------
1 file changed, 11 insertions(+), 12 deletions(-)
diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c
index 4d6549560b..82311bc645 100644
--- a/libavcodec/clearvideo.c
+++ b/libavcodec/clearvideo.c
@@ -362,19 +362,18 @@ static void mvi_update_row(MVInfo *mvi)
}
}
-static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc, int level)
+static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc)
{
TileInfo *ti;
int i, flags = 0;
int16_t bias = 0;
MV mv = { 0 };
- if (lc[level].flags_cb.table) {
- flags = get_vlc2(gb, lc[level].flags_cb.table, CLV_VLC_BITS, 2);
- }
+ if (lc->flags_cb.table)
+ flags = get_vlc2(gb, lc->flags_cb.table, CLV_VLC_BITS, 2);
- if (lc[level].mv_cb.table) {
- uint16_t mv_code = get_vlc2(gb, lc[level].mv_cb.table, CLV_VLC_BITS, 2);
+ if (lc->mv_cb.table) {
+ uint16_t mv_code = get_vlc2(gb, lc->mv_cb.table, CLV_VLC_BITS, 2);
if (mv_code != MV_ESC) {
mv.x = (int8_t)(mv_code & 0xff);
@@ -385,8 +384,8 @@ static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc, int l
}
}
- if (lc[level].bias_cb.table) {
- uint16_t bias_val = get_vlc2(gb, lc[level].bias_cb.table, CLV_VLC_BITS, 2);
+ if (lc->bias_cb.table) {
+ uint16_t bias_val = get_vlc2(gb, lc->bias_cb.table, CLV_VLC_BITS, 2);
if (bias_val != BIAS_ESC) {
bias = (int16_t)(bias_val);
@@ -406,7 +405,7 @@ static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc, int l
if (ti->flags) {
for (i = 0; i < 4; i++) {
if (ti->flags & (1 << i)) {
- TileInfo *subti = decode_tile_info(gb, lc, level + 1);
+ TileInfo *subti = decode_tile_info(gb, lc + 1);
ti->child[i] = subti;
}
}
@@ -599,7 +598,7 @@ static int clv_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
TileInfo *tile;
MV mv, cmv;
- tile = decode_tile_info(&c->gb, &lev[0], 0); // Y
+ tile = decode_tile_info(&c->gb, &lev[0]); // Y
if (!tile)
return AVERROR(ENOMEM);
mv = mvi_predict(&c->mvi, i, j, tile->mv);
@@ -614,14 +613,14 @@ static int clv_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
cmv.x /= 2;
cmv.y /= 2;
av_freep(&tile);
- tile = decode_tile_info(&c->gb, &lev[4], 0); // U
+ tile = decode_tile_info(&c->gb, &lev[4]); // U
if (!tile)
return AVERROR(ENOMEM);
ret = restore_tree(avctx, c->pic, c->prev, 1, x, y, size, tile, cmv);
if (ret < 0)
mb_ret = ret;
av_freep(&tile);
- tile = decode_tile_info(&c->gb, &lev[7], 0); // V
+ tile = decode_tile_info(&c->gb, &lev[7]); // V
if (!tile)
return AVERROR(ENOMEM);
ret = restore_tree(avctx, c->pic, c->prev, 2, x, y, size, tile, cmv);
--
2.34.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] 6+ messages in thread
* [FFmpeg-devel] [PATCH 2/5] avcodec/clearvideo: Move tile_do_block() upwards
2022-11-07 1:48 [FFmpeg-devel] [PATCH 1/5] avcodec/clearvideo: Remove unnecessary level parameter Andreas Rheinhardt
@ 2022-11-07 1:49 ` Andreas Rheinhardt
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 3/5] avcodec/clearvideo: Redo updating predicition Andreas Rheinhardt
` (3 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2022-11-07 1:49 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Will avoid a forward-declaration later.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/clearvideo.c | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c
index 82311bc645..6ea3d7b6a2 100644
--- a/libavcodec/clearvideo.c
+++ b/libavcodec/clearvideo.c
@@ -362,6 +362,20 @@ static void mvi_update_row(MVInfo *mvi)
}
}
+static int tile_do_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src,
+ int plane, int x, int y, int dx, int dy, int size, int bias)
+{
+ int ret;
+
+ if (!bias) {
+ ret = copy_block(avctx, dst, src, plane, x, y, dx, dy, size);
+ } else {
+ ret = copyadd_block(avctx, dst, src, plane, x, y, dx, dy, size, bias);
+ }
+
+ return ret;
+}
+
static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc)
{
TileInfo *ti;
@@ -414,20 +428,6 @@ static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc)
return ti;
}
-static int tile_do_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src,
- int plane, int x, int y, int dx, int dy, int size, int bias)
-{
- int ret;
-
- if (!bias) {
- ret = copy_block(avctx, dst, src, plane, x, y, dx, dy, size);
- } else {
- ret = copyadd_block(avctx, dst, src, plane, x, y, dx, dy, size, bias);
- }
-
- return ret;
-}
-
static int restore_tree(AVCodecContext *avctx, AVFrame *dst, AVFrame *src,
int plane, int x, int y, int size,
TileInfo *tile, MV root_mv)
--
2.34.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] 6+ messages in thread
* [FFmpeg-devel] [PATCH 3/5] avcodec/clearvideo: Redo updating predicition
2022-11-07 1:48 [FFmpeg-devel] [PATCH 1/5] avcodec/clearvideo: Remove unnecessary level parameter Andreas Rheinhardt
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 2/5] avcodec/clearvideo: Move tile_do_block() upwards Andreas Rheinhardt
@ 2022-11-07 1:49 ` Andreas Rheinhardt
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 4/5] avcodec/clearvideo: Use const where appropriate Andreas Rheinhardt
` (2 subsequent siblings)
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2022-11-07 1:49 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
This is in preparation for further commits.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/clearvideo.c | 24 ++++++++++++++++--------
1 file changed, 16 insertions(+), 8 deletions(-)
diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c
index 6ea3d7b6a2..11ae6ca9ad 100644
--- a/libavcodec/clearvideo.c
+++ b/libavcodec/clearvideo.c
@@ -296,7 +296,7 @@ static int copyadd_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src,
return 0;
}
-static MV mvi_predict(MVInfo *mvi, int mb_x, int mb_y, MV diff)
+static MV *mvi_predict(MVInfo *mvi, int mb_x, int mb_y)
{
MV res, pred_mv;
int left_mv, right_mv, top_mv, bot_mv;
@@ -336,10 +336,16 @@ static MV mvi_predict(MVInfo *mvi, int mb_x, int mb_y, MV diff)
res.y = bot_mv;
}
- mvi->mv[mvi->mb_stride + mb_x].x = res.x + diff.x;
- mvi->mv[mvi->mb_stride + mb_x].y = res.y + diff.y;
+ mvi->mv[mvi->mb_stride + mb_x].x = res.x;
+ mvi->mv[mvi->mb_stride + mb_x].y = res.y;
- return res;
+ return &mvi->mv[mvi->mb_stride + mb_x];
+}
+
+static void mvi_update_prediction(MV *mv, MV diff)
+{
+ mv->x += diff.x;
+ mv->y += diff.y;
}
static void mvi_reset(MVInfo *mvi, int mb_w, int mb_h, int mb_size)
@@ -575,11 +581,13 @@ static int clv_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
for (j = 0; j < c->pmb_height; j++) {
for (i = 0; i < c->pmb_width; i++) {
+ MV *mvp, mv;
if (get_bits_left(&c->gb) <= 0)
return AVERROR_INVALIDDATA;
- if (get_bits1(&c->gb)) {
- MV mv = mvi_predict(&c->mvi, i, j, zero_mv);
+ mvp = mvi_predict(&c->mvi, i, j);
+ mv = *mvp;
+ if (get_bits1(&c->gb)) {
for (plane = 0; plane < 3; plane++) {
int16_t x = plane == 0 ? i << c->tile_shift : i << (c->tile_shift - 1);
int16_t y = plane == 0 ? j << c->tile_shift : j << (c->tile_shift - 1);
@@ -596,15 +604,15 @@ static int clv_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
int y = j << c->tile_shift;
int size = 1 << c->tile_shift;
TileInfo *tile;
- MV mv, cmv;
+ MV cmv;
tile = decode_tile_info(&c->gb, &lev[0]); // Y
if (!tile)
return AVERROR(ENOMEM);
- mv = mvi_predict(&c->mvi, i, j, tile->mv);
ret = restore_tree(avctx, c->pic, c->prev, 0, x, y, size, tile, mv);
if (ret < 0)
mb_ret = ret;
+ mvi_update_prediction(mvp, tile->mv);
x = i << (c->tile_shift - 1);
y = j << (c->tile_shift - 1);
size = 1 << (c->tile_shift - 1);
--
2.34.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] 6+ messages in thread
* [FFmpeg-devel] [PATCH 4/5] avcodec/clearvideo: Use const where appropriate
2022-11-07 1:48 [FFmpeg-devel] [PATCH 1/5] avcodec/clearvideo: Remove unnecessary level parameter Andreas Rheinhardt
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 2/5] avcodec/clearvideo: Move tile_do_block() upwards Andreas Rheinhardt
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 3/5] avcodec/clearvideo: Redo updating predicition Andreas Rheinhardt
@ 2022-11-07 1:49 ` Andreas Rheinhardt
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 5/5] avcodec/clearvideo: Avoid allocations when decoding tiles Andreas Rheinhardt
2022-11-09 14:41 ` [FFmpeg-devel] [PATCH 1/5] avcodec/clearvideo: Remove unnecessary level parameter Andreas Rheinhardt
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2022-11-07 1:49 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/clearvideo.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c
index 11ae6ca9ad..d3cbd71f72 100644
--- a/libavcodec/clearvideo.c
+++ b/libavcodec/clearvideo.c
@@ -222,14 +222,15 @@ static int decode_mb(CLVContext *c, int x, int y)
return 0;
}
-static int copy_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src,
+static int copy_block(AVCodecContext *avctx, AVFrame *dst, const AVFrame *src,
int plane, int x, int y, int dx, int dy, int size)
{
int shift = plane > 0;
int sx = x + dx;
int sy = y + dy;
int sstride, dstride, soff, doff;
- uint8_t *sbuf, *dbuf;
+ uint8_t *dbuf;
+ const uint8_t *sbuf;
int i;
if (x < 0 || sx < 0 || y < 0 || sy < 0 ||
@@ -248,7 +249,7 @@ static int copy_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src,
for (i = 0; i < size; i++) {
uint8_t *dptr = &dbuf[doff];
- uint8_t *sptr = &sbuf[soff];
+ const uint8_t *sptr = &sbuf[soff];
memcpy(dptr, sptr, size);
doff += dstride;
@@ -258,7 +259,7 @@ static int copy_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src,
return 0;
}
-static int copyadd_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src,
+static int copyadd_block(AVCodecContext *avctx, AVFrame *dst, const AVFrame *src,
int plane, int x, int y, int dx, int dy, int size, int bias)
{
int shift = plane > 0;
@@ -267,7 +268,7 @@ static int copyadd_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src,
int sstride = src->linesize[plane];
int dstride = dst->linesize[plane];
int soff = sx + sy * sstride;
- uint8_t *sbuf = src->data[plane];
+ const uint8_t *sbuf = src->data[plane];
int doff = x + y * dstride;
uint8_t *dbuf = dst->data[plane];
int i, j;
@@ -281,7 +282,7 @@ static int copyadd_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src,
for (j = 0; j < size; j++) {
uint8_t *dptr = &dbuf[doff];
- uint8_t *sptr = &sbuf[soff];
+ const uint8_t *sptr = &sbuf[soff];
for (i = 0; i < size; i++) {
int val = sptr[i] + bias;
@@ -368,7 +369,7 @@ static void mvi_update_row(MVInfo *mvi)
}
}
-static int tile_do_block(AVCodecContext *avctx, AVFrame *dst, AVFrame *src,
+static int tile_do_block(AVCodecContext *avctx, AVFrame *dst, const AVFrame *src,
int plane, int x, int y, int dx, int dy, int size, int bias)
{
int ret;
--
2.34.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] 6+ messages in thread
* [FFmpeg-devel] [PATCH 5/5] avcodec/clearvideo: Avoid allocations when decoding tiles
2022-11-07 1:48 [FFmpeg-devel] [PATCH 1/5] avcodec/clearvideo: Remove unnecessary level parameter Andreas Rheinhardt
` (2 preceding siblings ...)
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 4/5] avcodec/clearvideo: Use const where appropriate Andreas Rheinhardt
@ 2022-11-07 1:49 ` Andreas Rheinhardt
2022-11-09 14:41 ` [FFmpeg-devel] [PATCH 1/5] avcodec/clearvideo: Remove unnecessary level parameter Andreas Rheinhardt
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2022-11-07 1:49 UTC (permalink / raw)
To: ffmpeg-devel; +Cc: Andreas Rheinhardt
Up until now, the ClearVideo decoder separates parsing tiles
and actually using the parsed information: The information is
instead stored in structures which are constantly allocated
and freed. This commit changes this to use the information
immediately, avoiding said allocations. This e.g. reduced
the amount of allocations for [1] from 2,866,462 to 24,720.
For said sample decoding speed improved by 143%.
[1]: https://samples.ffmpeg.org/V-codecs/UCOD/AccordianDance-300.avi
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/clearvideo.c | 99 +++++++++++++----------------------------
1 file changed, 31 insertions(+), 68 deletions(-)
diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c
index d3cbd71f72..e77661d187 100644
--- a/libavcodec/clearvideo.c
+++ b/libavcodec/clearvideo.c
@@ -59,13 +59,6 @@ typedef struct MVInfo {
MV *mv;
} MVInfo;
-typedef struct TileInfo {
- uint16_t flags;
- int16_t bias;
- MV mv;
- struct TileInfo *child[4];
-} TileInfo;
-
typedef struct CLVContext {
AVCodecContext *avctx;
IDCTDSPContext idsp;
@@ -383,12 +376,16 @@ static int tile_do_block(AVCodecContext *avctx, AVFrame *dst, const AVFrame *src
return ret;
}
-static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc)
+static int decode_tile(AVCodecContext *avctx, GetBitContext *gb,
+ const LevelCodes *lc,
+ AVFrame *dst, const AVFrame *src,
+ int plane, int x, int y, int size,
+ MV root_mv, MV *pred)
{
- TileInfo *ti;
int i, flags = 0;
int16_t bias = 0;
MV mv = { 0 };
+ int err;
if (lc->flags_cb.table)
flags = get_vlc2(gb, lc->flags_cb.table, CLV_VLC_BITS, 2);
@@ -403,7 +400,11 @@ static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc)
mv.x = get_sbits(gb, 8);
mv.y = get_sbits(gb, 8);
}
+ if (pred)
+ mvi_update_prediction(pred, mv);
}
+ mv.x += root_mv.x;
+ mv.y += root_mv.y;
if (lc->bias_cb.table) {
uint16_t bias_val = get_vlc2(gb, lc->bias_cb.table, CLV_VLC_BITS, 2);
@@ -415,55 +416,29 @@ static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc)
}
}
- ti = av_calloc(1, sizeof(*ti));
- if (!ti)
- return NULL;
-
- ti->flags = flags;
- ti->mv = mv;
- ti->bias = bias;
-
- if (ti->flags) {
- for (i = 0; i < 4; i++) {
- if (ti->flags & (1 << i)) {
- TileInfo *subti = decode_tile_info(gb, lc + 1);
- ti->child[i] = subti;
- }
- }
- }
-
- return ti;
-}
-
-static int restore_tree(AVCodecContext *avctx, AVFrame *dst, AVFrame *src,
- int plane, int x, int y, int size,
- TileInfo *tile, MV root_mv)
-{
- int ret;
- MV mv;
-
- mv.x = root_mv.x + tile->mv.x;
- mv.y = root_mv.y + tile->mv.y;
-
- if (!tile->flags) {
- ret = tile_do_block(avctx, dst, src, plane, x, y, mv.x, mv.y, size, tile->bias);
- } else {
- int i, hsize = size >> 1;
-
+ if (flags) {
+ int hsize = size >> 1;
for (i = 0; i < 4; i++) {
int xoff = (i & 2) == 0 ? 0 : hsize;
int yoff = (i & 1) == 0 ? 0 : hsize;
- if (tile->child[i]) {
- ret = restore_tree(avctx, dst, src, plane, x + xoff, y + yoff, hsize, tile->child[i], root_mv);
- av_freep(&tile->child[i]);
+ if (flags & (1 << i)) {
+ err = decode_tile(avctx, gb, lc + 1, dst, src, plane,
+ x + xoff, y + yoff, hsize, root_mv, NULL);
} else {
- ret = tile_do_block(avctx, dst, src, plane, x + xoff, y + yoff, mv.x, mv.y, hsize, tile->bias);
+ err = tile_do_block(avctx, dst, src, plane, x + xoff, y + yoff,
+ mv.x, mv.y, hsize, bias);
}
+ if (err < 0)
+ return err;
}
+ } else {
+ err = tile_do_block(avctx, dst, src, plane, x, y, mv.x, mv.y, size, bias);
+ if (err < 0)
+ return err;
}
- return ret;
+ return 0;
}
static void extend_edges(AVFrame *buf, int tile_size)
@@ -604,38 +579,26 @@ static int clv_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
int x = i << c->tile_shift;
int y = j << c->tile_shift;
int size = 1 << c->tile_shift;
- TileInfo *tile;
MV cmv;
- tile = decode_tile_info(&c->gb, &lev[0]); // Y
- if (!tile)
- return AVERROR(ENOMEM);
- ret = restore_tree(avctx, c->pic, c->prev, 0, x, y, size, tile, mv);
+ ret = decode_tile(avctx, &c->gb, &lev[0], c->pic, c->prev, // Y
+ 0, x, y, size, mv, mvp);
if (ret < 0)
mb_ret = ret;
- mvi_update_prediction(mvp, tile->mv);
x = i << (c->tile_shift - 1);
y = j << (c->tile_shift - 1);
size = 1 << (c->tile_shift - 1);
- cmv.x = mv.x + tile->mv.x;
- cmv.y = mv.y + tile->mv.y;
+ cmv = *mvp;
cmv.x /= 2;
cmv.y /= 2;
- av_freep(&tile);
- tile = decode_tile_info(&c->gb, &lev[4]); // U
- if (!tile)
- return AVERROR(ENOMEM);
- ret = restore_tree(avctx, c->pic, c->prev, 1, x, y, size, tile, cmv);
+ ret = decode_tile(avctx, &c->gb, &lev[4], c->pic, c->prev, // U
+ 1, x, y, size, cmv, NULL);
if (ret < 0)
mb_ret = ret;
- av_freep(&tile);
- tile = decode_tile_info(&c->gb, &lev[7]); // V
- if (!tile)
- return AVERROR(ENOMEM);
- ret = restore_tree(avctx, c->pic, c->prev, 2, x, y, size, tile, cmv);
+ ret = decode_tile(avctx, &c->gb, &lev[7], c->pic, c->prev, // U
+ 2, x, y, size, cmv, NULL);
if (ret < 0)
mb_ret = ret;
- av_freep(&tile);
}
}
mvi_update_row(&c->mvi);
--
2.34.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] 6+ messages in thread
* Re: [FFmpeg-devel] [PATCH 1/5] avcodec/clearvideo: Remove unnecessary level parameter
2022-11-07 1:48 [FFmpeg-devel] [PATCH 1/5] avcodec/clearvideo: Remove unnecessary level parameter Andreas Rheinhardt
` (3 preceding siblings ...)
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 5/5] avcodec/clearvideo: Avoid allocations when decoding tiles Andreas Rheinhardt
@ 2022-11-09 14:41 ` Andreas Rheinhardt
4 siblings, 0 replies; 6+ messages in thread
From: Andreas Rheinhardt @ 2022-11-09 14:41 UTC (permalink / raw)
To: ffmpeg-devel
Andreas Rheinhardt:
> Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
> ---
> libavcodec/clearvideo.c | 23 +++++++++++------------
> 1 file changed, 11 insertions(+), 12 deletions(-)
>
> diff --git a/libavcodec/clearvideo.c b/libavcodec/clearvideo.c
> index 4d6549560b..82311bc645 100644
> --- a/libavcodec/clearvideo.c
> +++ b/libavcodec/clearvideo.c
> @@ -362,19 +362,18 @@ static void mvi_update_row(MVInfo *mvi)
> }
> }
>
> -static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc, int level)
> +static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc)
> {
> TileInfo *ti;
> int i, flags = 0;
> int16_t bias = 0;
> MV mv = { 0 };
>
> - if (lc[level].flags_cb.table) {
> - flags = get_vlc2(gb, lc[level].flags_cb.table, CLV_VLC_BITS, 2);
> - }
> + if (lc->flags_cb.table)
> + flags = get_vlc2(gb, lc->flags_cb.table, CLV_VLC_BITS, 2);
>
> - if (lc[level].mv_cb.table) {
> - uint16_t mv_code = get_vlc2(gb, lc[level].mv_cb.table, CLV_VLC_BITS, 2);
> + if (lc->mv_cb.table) {
> + uint16_t mv_code = get_vlc2(gb, lc->mv_cb.table, CLV_VLC_BITS, 2);
>
> if (mv_code != MV_ESC) {
> mv.x = (int8_t)(mv_code & 0xff);
> @@ -385,8 +384,8 @@ static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc, int l
> }
> }
>
> - if (lc[level].bias_cb.table) {
> - uint16_t bias_val = get_vlc2(gb, lc[level].bias_cb.table, CLV_VLC_BITS, 2);
> + if (lc->bias_cb.table) {
> + uint16_t bias_val = get_vlc2(gb, lc->bias_cb.table, CLV_VLC_BITS, 2);
>
> if (bias_val != BIAS_ESC) {
> bias = (int16_t)(bias_val);
> @@ -406,7 +405,7 @@ static TileInfo *decode_tile_info(GetBitContext *gb, const LevelCodes *lc, int l
> if (ti->flags) {
> for (i = 0; i < 4; i++) {
> if (ti->flags & (1 << i)) {
> - TileInfo *subti = decode_tile_info(gb, lc, level + 1);
> + TileInfo *subti = decode_tile_info(gb, lc + 1);
> ti->child[i] = subti;
> }
> }
> @@ -599,7 +598,7 @@ static int clv_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
> TileInfo *tile;
> MV mv, cmv;
>
> - tile = decode_tile_info(&c->gb, &lev[0], 0); // Y
> + tile = decode_tile_info(&c->gb, &lev[0]); // Y
> if (!tile)
> return AVERROR(ENOMEM);
> mv = mvi_predict(&c->mvi, i, j, tile->mv);
> @@ -614,14 +613,14 @@ static int clv_decode_frame(AVCodecContext *avctx, AVFrame *rframe,
> cmv.x /= 2;
> cmv.y /= 2;
> av_freep(&tile);
> - tile = decode_tile_info(&c->gb, &lev[4], 0); // U
> + tile = decode_tile_info(&c->gb, &lev[4]); // U
> if (!tile)
> return AVERROR(ENOMEM);
> ret = restore_tree(avctx, c->pic, c->prev, 1, x, y, size, tile, cmv);
> if (ret < 0)
> mb_ret = ret;
> av_freep(&tile);
> - tile = decode_tile_info(&c->gb, &lev[7], 0); // V
> + tile = decode_tile_info(&c->gb, &lev[7]); // V
> if (!tile)
> return AVERROR(ENOMEM);
> ret = restore_tree(avctx, c->pic, c->prev, 2, x, y, size, tile, cmv);
Will apply 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] 6+ messages in thread
end of thread, other threads:[~2022-11-09 14:41 UTC | newest]
Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2022-11-07 1:48 [FFmpeg-devel] [PATCH 1/5] avcodec/clearvideo: Remove unnecessary level parameter Andreas Rheinhardt
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 2/5] avcodec/clearvideo: Move tile_do_block() upwards Andreas Rheinhardt
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 3/5] avcodec/clearvideo: Redo updating predicition Andreas Rheinhardt
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 4/5] avcodec/clearvideo: Use const where appropriate Andreas Rheinhardt
2022-11-07 1:49 ` [FFmpeg-devel] [PATCH 5/5] avcodec/clearvideo: Avoid allocations when decoding tiles Andreas Rheinhardt
2022-11-09 14:41 ` [FFmpeg-devel] [PATCH 1/5] avcodec/clearvideo: Remove unnecessary level parameter Andreas Rheinhardt
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