From: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
To: ffmpeg-devel@ffmpeg.org
Cc: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
Subject: [FFmpeg-devel] [PATCH 04/10] avcodec/h263: Move functions only used once to their caller
Date: Wed, 5 Jan 2022 22:56:04 +0100
Message-ID: <AM7PR03MB66609EF1DB1C4890CD1F7A038F4B9@AM7PR03MB6660.eurprd03.prod.outlook.com> (raw)
In-Reply-To: <AM7PR03MB6660E16D4E4345D825454C178F4B9@AM7PR03MB6660.eurprd03.prod.outlook.com>
In this case it means moving ff_h263_pred_dc() resp. ff_h263_pred_acdc()
to ituh263enc.c resp. ituh263dec.c.
Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
---
libavcodec/h263.c | 128 ----------------------------------------
libavcodec/h263.h | 2 -
libavcodec/ituh263dec.c | 89 +++++++++++++++++++++++++++-
libavcodec/ituh263enc.c | 43 +++++++++++++-
4 files changed, 130 insertions(+), 132 deletions(-)
diff --git a/libavcodec/h263.c b/libavcodec/h263.c
index f8fba3c9f4..b30ffaf878 100644
--- a/libavcodec/h263.c
+++ b/libavcodec/h263.c
@@ -102,47 +102,6 @@ void ff_h263_update_motion_val(MpegEncContext * s){
}
}
-int ff_h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr)
-{
- int x, y, wrap, a, c, pred_dc;
- int16_t *dc_val;
-
- /* find prediction */
- if (n < 4) {
- x = 2 * s->mb_x + (n & 1);
- y = 2 * s->mb_y + ((n & 2) >> 1);
- wrap = s->b8_stride;
- dc_val = s->dc_val[0];
- } else {
- x = s->mb_x;
- y = s->mb_y;
- wrap = s->mb_stride;
- dc_val = s->dc_val[n - 4 + 1];
- }
- /* B C
- * A X
- */
- a = dc_val[(x - 1) + (y) * wrap];
- c = dc_val[(x) + (y - 1) * wrap];
-
- /* No prediction outside GOB boundary */
- if(s->first_slice_line && n!=3){
- if(n!=2) c= 1024;
- if(n!=1 && s->mb_x == s->resync_mb_x) a= 1024;
- }
- /* just DC prediction */
- if (a != 1024 && c != 1024)
- pred_dc = (a + c) >> 1;
- else if (a != 1024)
- pred_dc = a;
- else
- pred_dc = c;
-
- /* we assume pred is positive */
- *dc_val_ptr = &dc_val[x + y * wrap];
- return pred_dc;
-}
-
void ff_h263_loop_filter(MpegEncContext * s){
int qp_c;
const int linesize = s->linesize;
@@ -228,93 +187,6 @@ void ff_h263_loop_filter(MpegEncContext * s){
}
}
-void ff_h263_pred_acdc(MpegEncContext * s, int16_t *block, int n)
-{
- int x, y, wrap, a, c, pred_dc, scale, i;
- int16_t *dc_val, *ac_val, *ac_val1;
-
- /* find prediction */
- if (n < 4) {
- x = 2 * s->mb_x + (n & 1);
- y = 2 * s->mb_y + (n>> 1);
- wrap = s->b8_stride;
- dc_val = s->dc_val[0];
- ac_val = s->ac_val[0][0];
- scale = s->y_dc_scale;
- } else {
- x = s->mb_x;
- y = s->mb_y;
- wrap = s->mb_stride;
- dc_val = s->dc_val[n - 4 + 1];
- ac_val = s->ac_val[n - 4 + 1][0];
- scale = s->c_dc_scale;
- }
-
- ac_val += ((y) * wrap + (x)) * 16;
- ac_val1 = ac_val;
-
- /* B C
- * A X
- */
- a = dc_val[(x - 1) + (y) * wrap];
- c = dc_val[(x) + (y - 1) * wrap];
-
- /* No prediction outside GOB boundary */
- if(s->first_slice_line && n!=3){
- if(n!=2) c= 1024;
- if(n!=1 && s->mb_x == s->resync_mb_x) a= 1024;
- }
-
- if (s->ac_pred) {
- pred_dc = 1024;
- if (s->h263_aic_dir) {
- /* left prediction */
- if (a != 1024) {
- ac_val -= 16;
- for(i=1;i<8;i++) {
- block[s->idsp.idct_permutation[i << 3]] += ac_val[i];
- }
- pred_dc = a;
- }
- } else {
- /* top prediction */
- if (c != 1024) {
- ac_val -= 16 * wrap;
- for(i=1;i<8;i++) {
- block[s->idsp.idct_permutation[i]] += ac_val[i + 8];
- }
- pred_dc = c;
- }
- }
- } else {
- /* just DC prediction */
- if (a != 1024 && c != 1024)
- pred_dc = (a + c) >> 1;
- else if (a != 1024)
- pred_dc = a;
- else
- pred_dc = c;
- }
-
- /* we assume pred is positive */
- block[0]=block[0]*scale + pred_dc;
-
- if (block[0] < 0)
- block[0] = 0;
- else
- block[0] |= 1;
-
- /* Update AC/DC tables */
- dc_val[(x) + (y) * wrap] = block[0];
-
- /* left copy */
- for(i=1;i<8;i++)
- ac_val1[i] = block[s->idsp.idct_permutation[i << 3]];
- /* top copy */
- for(i=1;i<8;i++)
- ac_val1[8 + i] = block[s->idsp.idct_permutation[i]];
-}
-
int16_t *ff_h263_pred_motion(MpegEncContext * s, int block, int dir,
int *px, int *py)
{
diff --git a/libavcodec/h263.h b/libavcodec/h263.h
index 84a3a19517..982e545491 100644
--- a/libavcodec/h263.h
+++ b/libavcodec/h263.h
@@ -74,8 +74,6 @@ void ff_h263_loop_filter(MpegEncContext * s);
int ff_h263_decode_mba(MpegEncContext *s);
void ff_h263_encode_mba(MpegEncContext *s);
void ff_init_qscale_tab(MpegEncContext *s);
-int ff_h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr);
-void ff_h263_pred_acdc(MpegEncContext * s, int16_t *block, int n);
/**
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index 3f982f414f..17af5d7f89 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -439,6 +439,93 @@ static void h263_decode_dquant(MpegEncContext *s){
ff_set_qscale(s, s->qscale);
}
+static void h263_pred_acdc(MpegEncContext * s, int16_t *block, int n)
+{
+ int x, y, wrap, a, c, pred_dc, scale;
+ int16_t *dc_val, *ac_val, *ac_val1;
+
+ /* find prediction */
+ if (n < 4) {
+ x = 2 * s->mb_x + (n & 1);
+ y = 2 * s->mb_y + (n>> 1);
+ wrap = s->b8_stride;
+ dc_val = s->dc_val[0];
+ ac_val = s->ac_val[0][0];
+ scale = s->y_dc_scale;
+ } else {
+ x = s->mb_x;
+ y = s->mb_y;
+ wrap = s->mb_stride;
+ dc_val = s->dc_val[n - 4 + 1];
+ ac_val = s->ac_val[n - 4 + 1][0];
+ scale = s->c_dc_scale;
+ }
+
+ ac_val += ((y) * wrap + (x)) * 16;
+ ac_val1 = ac_val;
+
+ /* B C
+ * A X
+ */
+ a = dc_val[(x - 1) + (y) * wrap];
+ c = dc_val[(x) + (y - 1) * wrap];
+
+ /* No prediction outside GOB boundary */
+ if (s->first_slice_line && n != 3) {
+ if (n != 2) c= 1024;
+ if (n != 1 && s->mb_x == s->resync_mb_x) a= 1024;
+ }
+
+ if (s->ac_pred) {
+ pred_dc = 1024;
+ if (s->h263_aic_dir) {
+ /* left prediction */
+ if (a != 1024) {
+ ac_val -= 16;
+ for (int i = 1; i < 8; i++) {
+ block[s->idsp.idct_permutation[i << 3]] += ac_val[i];
+ }
+ pred_dc = a;
+ }
+ } else {
+ /* top prediction */
+ if (c != 1024) {
+ ac_val -= 16 * wrap;
+ for (int i = 1; i < 8; i++) {
+ block[s->idsp.idct_permutation[i]] += ac_val[i + 8];
+ }
+ pred_dc = c;
+ }
+ }
+ } else {
+ /* just DC prediction */
+ if (a != 1024 && c != 1024)
+ pred_dc = (a + c) >> 1;
+ else if (a != 1024)
+ pred_dc = a;
+ else
+ pred_dc = c;
+ }
+
+ /* we assume pred is positive */
+ block[0] = block[0] * scale + pred_dc;
+
+ if (block[0] < 0)
+ block[0] = 0;
+ else
+ block[0] |= 1;
+
+ /* Update AC/DC tables */
+ dc_val[(x) + (y) * wrap] = block[0];
+
+ /* left copy */
+ for (int i = 1; i < 8; i++)
+ ac_val1[i] = block[s->idsp.idct_permutation[i << 3]];
+ /* top copy */
+ for (int i = 1; i < 8; i++)
+ ac_val1[8 + i] = block[s->idsp.idct_permutation[i]];
+}
+
static int h263_decode_block(MpegEncContext * s, int16_t * block,
int n, int coded)
{
@@ -579,7 +666,7 @@ retry:
}
not_coded:
if (s->mb_intra && s->h263_aic) {
- ff_h263_pred_acdc(s, block, n);
+ h263_pred_acdc(s, block, n);
i = 63;
}
s->block_last_index[n] = i;
diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c
index 79c8c9999e..d944c4879f 100644
--- a/libavcodec/ituh263enc.c
+++ b/libavcodec/ituh263enc.c
@@ -445,6 +445,47 @@ static void h263p_encode_umotion(PutBitContext *pb, int val)
}
}
+static int h263_pred_dc(MpegEncContext * s, int n, int16_t **dc_val_ptr)
+{
+ int x, y, wrap, a, c, pred_dc;
+ int16_t *dc_val;
+
+ /* find prediction */
+ if (n < 4) {
+ x = 2 * s->mb_x + (n & 1);
+ y = 2 * s->mb_y + ((n & 2) >> 1);
+ wrap = s->b8_stride;
+ dc_val = s->dc_val[0];
+ } else {
+ x = s->mb_x;
+ y = s->mb_y;
+ wrap = s->mb_stride;
+ dc_val = s->dc_val[n - 4 + 1];
+ }
+ /* B C
+ * A X
+ */
+ a = dc_val[(x - 1) + (y) * wrap];
+ c = dc_val[(x) + (y - 1) * wrap];
+
+ /* No prediction outside GOB boundary */
+ if (s->first_slice_line && n != 3) {
+ if (n != 2) c = 1024;
+ if (n != 1 && s->mb_x == s->resync_mb_x) a = 1024;
+ }
+ /* just DC prediction */
+ if (a != 1024 && c != 1024)
+ pred_dc = (a + c) >> 1;
+ else if (a != 1024)
+ pred_dc = a;
+ else
+ pred_dc = c;
+
+ /* we assume pred is positive */
+ *dc_val_ptr = &dc_val[x + y * wrap];
+ return pred_dc;
+}
+
void ff_h263_encode_mb(MpegEncContext * s,
int16_t block[6][64],
int motion_x, int motion_y)
@@ -552,7 +593,7 @@ void ff_h263_encode_mb(MpegEncContext * s,
if(i<4) scale= s->y_dc_scale;
else scale= s->c_dc_scale;
- pred_dc = ff_h263_pred_dc(s, i, &dc_ptr[i]);
+ pred_dc = h263_pred_dc(s, i, &dc_ptr[i]);
level -= pred_dc;
/* Quant */
if (level >= 0)
--
2.32.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".
next prev parent reply other threads:[~2022-01-05 21:56 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-01-05 21:53 [FFmpeg-devel] [PATCH 01/10] avcodec/mpeg12dec: Don't set write-only variable Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 02/10] avcodec/mpegvideo: Don't unnecessarily allocate buffers Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 03/10] avcodec/mpegvideo: Avoid macro/av_calloc for ordinary allocations Andreas Rheinhardt
2022-01-05 21:56 ` Andreas Rheinhardt [this message]
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 05/10] avcodec/mpeg4video: Skip unneeded element when parsing picture header Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 06/10] avcodec/mpeg4videodec: Fix data race when initializing VLCs Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 07/10] avcodec/rl: Don't pretend ff_rl_init() initializes a RLTable twice Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 08/10] avcodec/bitstream: Don't pretend VLCs to be initialized concurrently Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 09/10] avcodec: Remove unnecessary h263.h inclusions Andreas Rheinhardt
2022-01-05 21:56 ` [FFmpeg-devel] [PATCH 10/10] avcodec/avcodec: Remove outdated comment Andreas Rheinhardt
2022-01-05 22:21 ` Marvin Scholz
2022-01-06 7:08 ` Andreas Rheinhardt
2022-01-08 13:08 ` [FFmpeg-devel] [PATCH 01/10] avcodec/mpeg12dec: Don't set write-only variable Andreas Rheinhardt
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=AM7PR03MB66609EF1DB1C4890CD1F7A038F4B9@AM7PR03MB6660.eurprd03.prod.outlook.com \
--to=andreas.rheinhardt@outlook.com \
--cc=ffmpeg-devel@ffmpeg.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
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