diff options
author | Michael Niedermayer <michaelni@gmx.at> | 2013-04-05 22:00:38 +0200 |
---|---|---|
committer | Michael Niedermayer <michaelni@gmx.at> | 2013-04-05 22:00:38 +0200 |
commit | 473d1297427fff8cd00b08ce054e80a262efc6eb (patch) | |
tree | 96d18e2e0f83879bc53c35b320ac26eb5eee2374 /libavcodec/h261enc.c | |
parent | 04b0fd7e91b9a4f5e58744a61d8993bb7898b13b (diff) | |
parent | 0404ec619d43f27b87c424aa1a572a6699fe6a31 (diff) | |
download | ffmpeg-473d1297427fff8cd00b08ce054e80a262efc6eb.tar.gz |
Merge commit '0404ec619d43f27b87c424aa1a572a6699fe6a31'
* commit '0404ec619d43f27b87c424aa1a572a6699fe6a31':
h261: cosmetics: Move functions to avoid forward declarations
Conflicts:
libavcodec/h261dec.c
libavcodec/h261enc.c
Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec/h261enc.c')
-rw-r--r-- | libavcodec/h261enc.c | 149 |
1 files changed, 73 insertions, 76 deletions
diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index 386e200003..bfdb3e68b6 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -32,9 +32,6 @@ #include "h261.h" #include "h261data.h" -static void h261_encode_block(H261Context *h, int16_t *block, - int n); - int ff_h261_get_picture_format(int width, int height) { // QCIF @@ -156,6 +153,79 @@ static inline int get_cbp(MpegEncContext *s, int16_t block[6][64]) return cbp; } +/** + * Encode an 8x8 block. + * @param block the 8x8 block + * @param n block index (0-3 are luma, 4-5 are chroma) + */ +static void h261_encode_block(H261Context *h, int16_t *block, int n) +{ + MpegEncContext *const s = &h->s; + int level, run, i, j, last_index, last_non_zero, sign, slevel, code; + RLTable *rl; + + rl = &ff_h261_rl_tcoeff; + if (s->mb_intra) { + /* DC coef */ + level = block[0]; + /* 255 cannot be represented, so we clamp */ + if (level > 254) { + level = 254; + block[0] = 254; + } + /* 0 cannot be represented also */ + else if (level < 1) { + level = 1; + block[0] = 1; + } + if (level == 128) + put_bits(&s->pb, 8, 0xff); + else + put_bits(&s->pb, 8, level); + i = 1; + } else if ((block[0] == 1 || block[0] == -1) && + (s->block_last_index[n] > -1)) { + // special case + put_bits(&s->pb, 2, block[0] > 0 ? 2 : 3); + i = 1; + } else { + i = 0; + } + + /* AC coefs */ + last_index = s->block_last_index[n]; + last_non_zero = i - 1; + for (; i <= last_index; i++) { + j = s->intra_scantable.permutated[i]; + level = block[j]; + if (level) { + run = i - last_non_zero - 1; + sign = 0; + slevel = level; + if (level < 0) { + sign = 1; + level = -level; + } + code = get_rl_index(rl, 0 /*no last in H.261, EOB is used*/, + run, level); + if (run == 0 && level < 16) + code += 1; + put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]); + if (code == rl->n) { + put_bits(&s->pb, 6, run); + av_assert1(slevel != 0); + av_assert1(level <= 127); + put_sbits(&s->pb, 8, slevel); + } else { + put_bits(&s->pb, 1, sign); + } + last_non_zero = i; + } + } + if (last_index > -1) + put_bits(&s->pb, rl->table_vlc[0][1], rl->table_vlc[0][0]); // EOB +} + void ff_h261_encode_mb(MpegEncContext *s, int16_t block[6][64], int motion_x, int motion_y) { @@ -253,79 +323,6 @@ void ff_h261_encode_init(MpegEncContext *s) s->c_dc_scale_table = ff_mpeg1_dc_scale_table; } -/** - * Encode an 8x8 block. - * @param block the 8x8 block - * @param n block index (0-3 are luma, 4-5 are chroma) - */ -static void h261_encode_block(H261Context *h, int16_t *block, int n) -{ - MpegEncContext *const s = &h->s; - int level, run, i, j, last_index, last_non_zero, sign, slevel, code; - RLTable *rl; - - rl = &ff_h261_rl_tcoeff; - if (s->mb_intra) { - /* DC coef */ - level = block[0]; - /* 255 cannot be represented, so we clamp */ - if (level > 254) { - level = 254; - block[0] = 254; - } - /* 0 cannot be represented also */ - else if (level < 1) { - level = 1; - block[0] = 1; - } - if (level == 128) - put_bits(&s->pb, 8, 0xff); - else - put_bits(&s->pb, 8, level); - i = 1; - } else if ((block[0] == 1 || block[0] == -1) && - (s->block_last_index[n] > -1)) { - // special case - put_bits(&s->pb, 2, block[0] > 0 ? 2 : 3); - i = 1; - } else { - i = 0; - } - - /* AC coefs */ - last_index = s->block_last_index[n]; - last_non_zero = i - 1; - for (; i <= last_index; i++) { - j = s->intra_scantable.permutated[i]; - level = block[j]; - if (level) { - run = i - last_non_zero - 1; - sign = 0; - slevel = level; - if (level < 0) { - sign = 1; - level = -level; - } - code = get_rl_index(rl, 0 /*no last in H.261, EOB is used*/, - run, level); - if (run == 0 && level < 16) - code += 1; - put_bits(&s->pb, rl->table_vlc[code][1], rl->table_vlc[code][0]); - if (code == rl->n) { - put_bits(&s->pb, 6, run); - av_assert1(slevel != 0); - av_assert1(level <= 127); - put_sbits(&s->pb, 8, slevel); - } else { - put_bits(&s->pb, 1, sign); - } - last_non_zero = i; - } - } - if (last_index > -1) - put_bits(&s->pb, rl->table_vlc[0][1], rl->table_vlc[0][0]); // EOB -} - FF_MPV_GENERIC_CLASS(h261) AVCodec ff_h261_encoder = { |