aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec/mpegvideo.c
diff options
context:
space:
mode:
authorAnton Khirnov <anton@khirnov.net>2013-12-03 07:52:33 +0100
committerAnton Khirnov <anton@khirnov.net>2014-01-03 16:54:00 +0100
commita4d0c6e0503562d4cc8f9f6d02d84d7b32583b15 (patch)
treed8bc6a7950ee7a5d52ae9af2683e9d9417627e4e /libavcodec/mpegvideo.c
parentaec25b1c4650944d32706bfd40eb02bbd5587303 (diff)
downloadffmpeg-a4d0c6e0503562d4cc8f9f6d02d84d7b32583b15.tar.gz
mpegvideo: move dct_unquantize functions up to avoid forward declarations
Diffstat (limited to 'libavcodec/mpegvideo.c')
-rw-r--r--libavcodec/mpegvideo.c451
1 files changed, 218 insertions, 233 deletions
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 6b3a6ee31a..0003aedc81 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -42,21 +42,6 @@
#include "thread.h"
#include <limits.h>
-static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-static void dct_unquantize_h263_intra_c(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-static void dct_unquantize_h263_inter_c(MpegEncContext *s,
- int16_t *block, int n, int qscale);
-
static const uint8_t ff_default_chroma_qscale_table[32] = {
// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
0, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15,
@@ -123,6 +108,224 @@ const enum AVPixelFormat ff_pixfmt_list_420[] = {
AV_PIX_FMT_NONE
};
+static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, nCoeffs;
+ const uint16_t *quant_matrix;
+
+ nCoeffs= s->block_last_index[n];
+
+ if (n < 4)
+ block[0] = block[0] * s->y_dc_scale;
+ else
+ block[0] = block[0] * s->c_dc_scale;
+ /* XXX: only mpeg1 */
+ quant_matrix = s->intra_matrix;
+ for(i=1;i<=nCoeffs;i++) {
+ int j= s->intra_scantable.permutated[i];
+ level = block[j];
+ if (level) {
+ if (level < 0) {
+ level = -level;
+ level = (int)(level * qscale * quant_matrix[j]) >> 3;
+ level = (level - 1) | 1;
+ level = -level;
+ } else {
+ level = (int)(level * qscale * quant_matrix[j]) >> 3;
+ level = (level - 1) | 1;
+ }
+ block[j] = level;
+ }
+ }
+}
+
+static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, nCoeffs;
+ const uint16_t *quant_matrix;
+
+ nCoeffs= s->block_last_index[n];
+
+ quant_matrix = s->inter_matrix;
+ for(i=0; i<=nCoeffs; i++) {
+ int j= s->intra_scantable.permutated[i];
+ level = block[j];
+ if (level) {
+ if (level < 0) {
+ level = -level;
+ level = (((level << 1) + 1) * qscale *
+ ((int) (quant_matrix[j]))) >> 4;
+ level = (level - 1) | 1;
+ level = -level;
+ } else {
+ level = (((level << 1) + 1) * qscale *
+ ((int) (quant_matrix[j]))) >> 4;
+ level = (level - 1) | 1;
+ }
+ block[j] = level;
+ }
+ }
+}
+
+static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, nCoeffs;
+ const uint16_t *quant_matrix;
+
+ if(s->alternate_scan) nCoeffs= 63;
+ else nCoeffs= s->block_last_index[n];
+
+ if (n < 4)
+ block[0] = block[0] * s->y_dc_scale;
+ else
+ block[0] = block[0] * s->c_dc_scale;
+ quant_matrix = s->intra_matrix;
+ for(i=1;i<=nCoeffs;i++) {
+ int j= s->intra_scantable.permutated[i];
+ level = block[j];
+ if (level) {
+ if (level < 0) {
+ level = -level;
+ level = (int)(level * qscale * quant_matrix[j]) >> 3;
+ level = -level;
+ } else {
+ level = (int)(level * qscale * quant_matrix[j]) >> 3;
+ }
+ block[j] = level;
+ }
+ }
+}
+
+static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, nCoeffs;
+ const uint16_t *quant_matrix;
+ int sum=-1;
+
+ if(s->alternate_scan) nCoeffs= 63;
+ else nCoeffs= s->block_last_index[n];
+
+ if (n < 4)
+ block[0] = block[0] * s->y_dc_scale;
+ else
+ block[0] = block[0] * s->c_dc_scale;
+ quant_matrix = s->intra_matrix;
+ for(i=1;i<=nCoeffs;i++) {
+ int j= s->intra_scantable.permutated[i];
+ level = block[j];
+ if (level) {
+ if (level < 0) {
+ level = -level;
+ level = (int)(level * qscale * quant_matrix[j]) >> 3;
+ level = -level;
+ } else {
+ level = (int)(level * qscale * quant_matrix[j]) >> 3;
+ }
+ block[j] = level;
+ sum+=level;
+ }
+ }
+ block[63]^=sum&1;
+}
+
+static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, nCoeffs;
+ const uint16_t *quant_matrix;
+ int sum=-1;
+
+ if(s->alternate_scan) nCoeffs= 63;
+ else nCoeffs= s->block_last_index[n];
+
+ quant_matrix = s->inter_matrix;
+ for(i=0; i<=nCoeffs; i++) {
+ int j= s->intra_scantable.permutated[i];
+ level = block[j];
+ if (level) {
+ if (level < 0) {
+ level = -level;
+ level = (((level << 1) + 1) * qscale *
+ ((int) (quant_matrix[j]))) >> 4;
+ level = -level;
+ } else {
+ level = (((level << 1) + 1) * qscale *
+ ((int) (quant_matrix[j]))) >> 4;
+ }
+ block[j] = level;
+ sum+=level;
+ }
+ }
+ block[63]^=sum&1;
+}
+
+static void dct_unquantize_h263_intra_c(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, qmul, qadd;
+ int nCoeffs;
+
+ assert(s->block_last_index[n]>=0);
+
+ qmul = qscale << 1;
+
+ if (!s->h263_aic) {
+ if (n < 4)
+ block[0] = block[0] * s->y_dc_scale;
+ else
+ block[0] = block[0] * s->c_dc_scale;
+ qadd = (qscale - 1) | 1;
+ }else{
+ qadd = 0;
+ }
+ if(s->ac_pred)
+ nCoeffs=63;
+ else
+ nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
+
+ for(i=1; i<=nCoeffs; i++) {
+ level = block[i];
+ if (level) {
+ if (level < 0) {
+ level = level * qmul - qadd;
+ } else {
+ level = level * qmul + qadd;
+ }
+ block[i] = level;
+ }
+ }
+}
+
+static void dct_unquantize_h263_inter_c(MpegEncContext *s,
+ int16_t *block, int n, int qscale)
+{
+ int i, level, qmul, qadd;
+ int nCoeffs;
+
+ assert(s->block_last_index[n]>=0);
+
+ qadd = (qscale - 1) | 1;
+ qmul = qscale << 1;
+
+ nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
+
+ for(i=0; i<=nCoeffs; i++) {
+ level = block[i];
+ if (level) {
+ if (level < 0) {
+ level = level * qmul - qadd;
+ } else {
+ level = level * qmul + qadd;
+ }
+ block[i] = level;
+ }
+ }
+}
+
static void mpeg_er_decode_mb(void *opaque, int ref, int mv_dir, int mv_type,
int (*mv)[2][4][2],
int mb_x, int mb_y, int mb_intra, int mb_skipped)
@@ -2286,224 +2489,6 @@ void ff_mpeg_flush(AVCodecContext *avctx){
s->pp_time=0;
}
-static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, nCoeffs;
- const uint16_t *quant_matrix;
-
- nCoeffs= s->block_last_index[n];
-
- if (n < 4)
- block[0] = block[0] * s->y_dc_scale;
- else
- block[0] = block[0] * s->c_dc_scale;
- /* XXX: only mpeg1 */
- quant_matrix = s->intra_matrix;
- for(i=1;i<=nCoeffs;i++) {
- int j= s->intra_scantable.permutated[i];
- level = block[j];
- if (level) {
- if (level < 0) {
- level = -level;
- level = (int)(level * qscale * quant_matrix[j]) >> 3;
- level = (level - 1) | 1;
- level = -level;
- } else {
- level = (int)(level * qscale * quant_matrix[j]) >> 3;
- level = (level - 1) | 1;
- }
- block[j] = level;
- }
- }
-}
-
-static void dct_unquantize_mpeg1_inter_c(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, nCoeffs;
- const uint16_t *quant_matrix;
-
- nCoeffs= s->block_last_index[n];
-
- quant_matrix = s->inter_matrix;
- for(i=0; i<=nCoeffs; i++) {
- int j= s->intra_scantable.permutated[i];
- level = block[j];
- if (level) {
- if (level < 0) {
- level = -level;
- level = (((level << 1) + 1) * qscale *
- ((int) (quant_matrix[j]))) >> 4;
- level = (level - 1) | 1;
- level = -level;
- } else {
- level = (((level << 1) + 1) * qscale *
- ((int) (quant_matrix[j]))) >> 4;
- level = (level - 1) | 1;
- }
- block[j] = level;
- }
- }
-}
-
-static void dct_unquantize_mpeg2_intra_c(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, nCoeffs;
- const uint16_t *quant_matrix;
-
- if(s->alternate_scan) nCoeffs= 63;
- else nCoeffs= s->block_last_index[n];
-
- if (n < 4)
- block[0] = block[0] * s->y_dc_scale;
- else
- block[0] = block[0] * s->c_dc_scale;
- quant_matrix = s->intra_matrix;
- for(i=1;i<=nCoeffs;i++) {
- int j= s->intra_scantable.permutated[i];
- level = block[j];
- if (level) {
- if (level < 0) {
- level = -level;
- level = (int)(level * qscale * quant_matrix[j]) >> 3;
- level = -level;
- } else {
- level = (int)(level * qscale * quant_matrix[j]) >> 3;
- }
- block[j] = level;
- }
- }
-}
-
-static void dct_unquantize_mpeg2_intra_bitexact(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, nCoeffs;
- const uint16_t *quant_matrix;
- int sum=-1;
-
- if(s->alternate_scan) nCoeffs= 63;
- else nCoeffs= s->block_last_index[n];
-
- if (n < 4)
- block[0] = block[0] * s->y_dc_scale;
- else
- block[0] = block[0] * s->c_dc_scale;
- quant_matrix = s->intra_matrix;
- for(i=1;i<=nCoeffs;i++) {
- int j= s->intra_scantable.permutated[i];
- level = block[j];
- if (level) {
- if (level < 0) {
- level = -level;
- level = (int)(level * qscale * quant_matrix[j]) >> 3;
- level = -level;
- } else {
- level = (int)(level * qscale * quant_matrix[j]) >> 3;
- }
- block[j] = level;
- sum+=level;
- }
- }
- block[63]^=sum&1;
-}
-
-static void dct_unquantize_mpeg2_inter_c(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, nCoeffs;
- const uint16_t *quant_matrix;
- int sum=-1;
-
- if(s->alternate_scan) nCoeffs= 63;
- else nCoeffs= s->block_last_index[n];
-
- quant_matrix = s->inter_matrix;
- for(i=0; i<=nCoeffs; i++) {
- int j= s->intra_scantable.permutated[i];
- level = block[j];
- if (level) {
- if (level < 0) {
- level = -level;
- level = (((level << 1) + 1) * qscale *
- ((int) (quant_matrix[j]))) >> 4;
- level = -level;
- } else {
- level = (((level << 1) + 1) * qscale *
- ((int) (quant_matrix[j]))) >> 4;
- }
- block[j] = level;
- sum+=level;
- }
- }
- block[63]^=sum&1;
-}
-
-static void dct_unquantize_h263_intra_c(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, qmul, qadd;
- int nCoeffs;
-
- assert(s->block_last_index[n]>=0);
-
- qmul = qscale << 1;
-
- if (!s->h263_aic) {
- if (n < 4)
- block[0] = block[0] * s->y_dc_scale;
- else
- block[0] = block[0] * s->c_dc_scale;
- qadd = (qscale - 1) | 1;
- }else{
- qadd = 0;
- }
- if(s->ac_pred)
- nCoeffs=63;
- else
- nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
-
- for(i=1; i<=nCoeffs; i++) {
- level = block[i];
- if (level) {
- if (level < 0) {
- level = level * qmul - qadd;
- } else {
- level = level * qmul + qadd;
- }
- block[i] = level;
- }
- }
-}
-
-static void dct_unquantize_h263_inter_c(MpegEncContext *s,
- int16_t *block, int n, int qscale)
-{
- int i, level, qmul, qadd;
- int nCoeffs;
-
- assert(s->block_last_index[n]>=0);
-
- qadd = (qscale - 1) | 1;
- qmul = qscale << 1;
-
- nCoeffs= s->inter_scantable.raster_end[ s->block_last_index[n] ];
-
- for(i=0; i<=nCoeffs; i++) {
- level = block[i];
- if (level) {
- if (level < 0) {
- level = level * qmul - qadd;
- } else {
- level = level * qmul + qadd;
- }
- block[i] = level;
- }
- }
-}
-
/**
* set qscale and update qscale dependent variables.
*/