diff --git a/libavcodec/Makefile b/libavcodec/Makefile index 0107460154..96cc258099 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -76,7 +76,8 @@ OBJS-$(CONFIG_MPEGAUDIODSP) += mpegaudiodsp.o \ mpegaudiodsp_fixed.o \ mpegaudiodsp_float.o OBJS-$(CONFIG_MPEGVIDEO) += mpegvideo.o mpegvideodsp.o rl.o \ - mpegvideo_motion.o mpegutils.o + mpegvideo_motion.o mpegutils.o \ + mpegvideodata.o OBJS-$(CONFIG_MPEGVIDEOENC) += mpegvideo_enc.o mpeg12data.o \ motion_est.o ratecontrol.o \ mpegvideoencdsp.o diff --git a/libavcodec/flvdec.c b/libavcodec/flvdec.c index 0a6f268579..71617947bb 100644 --- a/libavcodec/flvdec.c +++ b/libavcodec/flvdec.c @@ -23,6 +23,7 @@ #include "flv.h" #include "h263.h" #include "mpegvideo.h" +#include "mpegvideodata.h" void ff_flv2_decode_ac_esc(GetBitContext *gb, int *level, int *run, int *last) { diff --git a/libavcodec/flvenc.c b/libavcodec/flvenc.c index e14a1056e9..f52f66aed8 100644 --- a/libavcodec/flvenc.c +++ b/libavcodec/flvenc.c @@ -21,6 +21,7 @@ #include "flv.h" #include "h263.h" #include "mpegvideo.h" +#include "mpegvideodata.h" void ff_flv_encode_picture_header(MpegEncContext *s, int picture_number) { diff --git a/libavcodec/h261enc.c b/libavcodec/h261enc.c index f24e590f92..ae61fc24c4 100644 --- a/libavcodec/h261enc.c +++ b/libavcodec/h261enc.c @@ -31,6 +31,7 @@ #include "mpegvideo.h" #include "h263.h" #include "h261.h" +#include "mpegvideodata.h" int ff_h261_get_picture_format(int width, int height) { diff --git a/libavcodec/intelh263dec.c b/libavcodec/intelh263dec.c index e34da5c6f5..3f37489aa9 100644 --- a/libavcodec/intelh263dec.c +++ b/libavcodec/intelh263dec.c @@ -20,6 +20,7 @@ #include "mpegvideo.h" #include "h263.h" +#include "mpegvideodata.h" /* don't understand why they choose a different header ! */ int ff_intel_h263_decode_picture_header(MpegEncContext *s) diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c index 1f9ac27dd3..8f69f0f918 100644 --- a/libavcodec/ituh263dec.c +++ b/libavcodec/ituh263dec.c @@ -41,6 +41,7 @@ #include "unary.h" #include "flv.h" #include "mpeg4video.h" +#include "mpegvideodata.h" // The defines below define the number of bits that are read at once for // reading vlc values. Changing these may improve speed and data cache needs diff --git a/libavcodec/ituh263enc.c b/libavcodec/ituh263enc.c index 3afc238e35..952e15ce24 100644 --- a/libavcodec/ituh263enc.c +++ b/libavcodec/ituh263enc.c @@ -32,6 +32,7 @@ #include "libavutil/attributes.h" #include "avcodec.h" #include "mpegvideo.h" +#include "mpegvideodata.h" #include "h263.h" #include "mathops.h" #include "mpegutils.h" diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c index 900761d9c9..69c6d0a09a 100644 --- a/libavcodec/mpeg12.c +++ b/libavcodec/mpeg12.c @@ -32,6 +32,7 @@ #include "error_resilience.h" #include "mpeg12.h" #include "mpeg12data.h" +#include "mpegvideodata.h" #include "bytestream.h" #include "thread.h" diff --git a/libavcodec/mpeg12dec.c b/libavcodec/mpeg12dec.c index c66d6aa508..d4c517d82e 100644 --- a/libavcodec/mpeg12dec.c +++ b/libavcodec/mpeg12dec.c @@ -41,6 +41,7 @@ #include "mpeg12data.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodata.h" #include "thread.h" #include "version.h" #include "xvmc_internal.h" diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c index 7e36170d43..eb71a86209 100644 --- a/libavcodec/mpeg4videodec.c +++ b/libavcodec/mpeg4videodec.c @@ -25,6 +25,7 @@ #include "internal.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodata.h" #include "mpeg4video.h" #include "h263.h" #include "thread.h" diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c index 49f2e66177..f380aeeb6d 100644 --- a/libavcodec/mpegvideo.c +++ b/libavcodec/mpegvideo.c @@ -39,6 +39,7 @@ #include "mathops.h" #include "mpegutils.h" #include "mpegvideo.h" +#include "mpegvideodata.h" #include "mjpegenc.h" #include "msmpeg4.h" #include "qpeldsp.h" @@ -47,89 +48,6 @@ #include "wmv2.h" #include -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, - 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 -}; - -const uint8_t ff_mpeg1_dc_scale_table[128] = { -// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, - 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, -}; - -static const uint8_t mpeg2_dc_scale_table1[128] = { -// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, - 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4, 4,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 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, - 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, -}; - -const uint8_t *const ff_mpeg2_dc_scale_table[4] = { - ff_mpeg1_dc_scale_table, - mpeg2_dc_scale_table1, - mpeg2_dc_scale_table2, - mpeg2_dc_scale_table3, -}; - -const uint8_t ff_alternate_horizontal_scan[64] = { - 0, 1, 2, 3, 8, 9, 16, 17, - 10, 11, 4, 5, 6, 7, 15, 14, - 13, 12, 19, 18, 24, 25, 32, 33, - 26, 27, 20, 21, 22, 23, 28, 29, - 30, 31, 34, 35, 40, 41, 48, 49, - 42, 43, 36, 37, 38, 39, 44, 45, - 46, 47, 50, 51, 56, 57, 58, 59, - 52, 53, 54, 55, 60, 61, 62, 63, -}; - -const uint8_t ff_alternate_vertical_scan[64] = { - 0, 8, 16, 24, 1, 9, 2, 10, - 17, 25, 32, 40, 48, 56, 57, 49, - 41, 33, 26, 18, 3, 11, 4, 12, - 19, 27, 34, 42, 50, 58, 35, 43, - 51, 59, 20, 28, 5, 13, 6, 14, - 21, 29, 36, 44, 52, 60, 37, 45, - 53, 61, 22, 30, 7, 15, 23, 31, - 38, 46, 54, 62, 39, 47, 55, 63, -}; - static void dct_unquantize_mpeg1_intra_c(MpegEncContext *s, int16_t *block, int n, int qscale) { diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h index 48c9cffc89..7fd4f1104f 100644 --- a/libavcodec/mpegvideo.h +++ b/libavcodec/mpegvideo.h @@ -88,10 +88,6 @@ enum OutputFormat { #define EXT_START_CODE 0x000001b5 #define USER_START_CODE 0x000001b2 -/* encoding scans */ -extern const uint8_t ff_alternate_horizontal_scan[64]; -extern const uint8_t ff_alternate_vertical_scan[64]; - struct MpegEncContext; /** @@ -821,10 +817,6 @@ int ff_epzs_motion_search(MpegEncContext * s, int *mx_ptr, int *my_ptr, int ff_get_mb_score(MpegEncContext * s, int mx, int my, int src_index, int ref_index, int size, int h, int add_rate); -/* mpeg12.c */ -extern const uint8_t ff_mpeg1_dc_scale_table[128]; -extern const uint8_t * const ff_mpeg2_dc_scale_table[4]; - void ff_mpeg1_encode_picture_header(MpegEncContext *s, int picture_number); void ff_mpeg1_encode_mb(MpegEncContext *s, int16_t block[8][64], diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c index a47781812f..cb8a406819 100644 --- a/libavcodec/mpegvideo_enc.c +++ b/libavcodec/mpegvideo_enc.c @@ -40,6 +40,7 @@ #include "idctdsp.h" #include "mpeg12.h" #include "mpegvideo.h" +#include "mpegvideodata.h" #include "h261.h" #include "h263.h" #include "mjpegenc_common.h" diff --git a/libavcodec/mpegvideodata.c b/libavcodec/mpegvideodata.c new file mode 100644 index 0000000000..f27dd90a93 --- /dev/null +++ b/libavcodec/mpegvideodata.c @@ -0,0 +1,102 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include + +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, + 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31 +}; + +const uint8_t ff_mpeg1_dc_scale_table[128] = { +// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 8, 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2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, + 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, +}; + +static const uint8_t mpeg2_dc_scale_table3[128] = { +// 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, + 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, +}; + +const uint8_t *const ff_mpeg2_dc_scale_table[4] = { + ff_mpeg1_dc_scale_table, + mpeg2_dc_scale_table1, + mpeg2_dc_scale_table2, + mpeg2_dc_scale_table3, +}; + +const uint8_t ff_alternate_horizontal_scan[64] = { + 0, 1, 2, 3, 8, 9, 16, 17, + 10, 11, 4, 5, 6, 7, 15, 14, + 13, 12, 19, 18, 24, 25, 32, 33, + 26, 27, 20, 21, 22, 23, 28, 29, + 30, 31, 34, 35, 40, 41, 48, 49, + 42, 43, 36, 37, 38, 39, 44, 45, + 46, 47, 50, 51, 56, 57, 58, 59, + 52, 53, 54, 55, 60, 61, 62, 63, +}; + +const uint8_t ff_alternate_vertical_scan[64] = { + 0, 8, 16, 24, 1, 9, 2, 10, + 17, 25, 32, 40, 48, 56, 57, 49, + 41, 33, 26, 18, 3, 11, 4, 12, + 19, 27, 34, 42, 50, 58, 35, 43, + 51, 59, 20, 28, 5, 13, 6, 14, + 21, 29, 36, 44, 52, 60, 37, 45, + 53, 61, 22, 30, 7, 15, 23, 31, + 38, 46, 54, 62, 39, 47, 55, 63, +}; diff --git a/libavcodec/mpegvideodata.h b/libavcodec/mpegvideodata.h new file mode 100644 index 0000000000..d3ace23d56 --- /dev/null +++ b/libavcodec/mpegvideodata.h @@ -0,0 +1,33 @@ +/* + * This file is part of Libav. + * + * Libav is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * Libav is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with Libav; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_MPEGVIDEODATA_H +#define AVCODEC_MPEGVIDEODATA_H + +#include + +/* encoding scans */ +extern const uint8_t ff_alternate_horizontal_scan[64]; +extern const uint8_t ff_alternate_vertical_scan[64]; + +extern const uint8_t ff_mpeg1_dc_scale_table[128]; +extern const uint8_t * const ff_mpeg2_dc_scale_table[4]; + +extern const uint8_t ff_default_chroma_qscale_table[32]; + +#endif /* AVCODEC_MPEGVIDEODATA_H */ diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c index 95b5c93ea3..94bd86e0e3 100644 --- a/libavcodec/msmpeg4.c +++ b/libavcodec/msmpeg4.c @@ -35,6 +35,7 @@ #include "h263.h" #include "mpeg4video.h" #include "msmpeg4data.h" +#include "mpegvideodata.h" #include "vc1data.h" /* diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c index 20230f40bd..52be052537 100644 --- a/libavcodec/rv10.c +++ b/libavcodec/rv10.c @@ -36,6 +36,7 @@ #include "mpeg_er.h" #include "mpegvideo.h" #include "mpeg4video.h" +#include "mpegvideodata.h" #define RV_GET_MAJOR_VER(x) ((x) >> 28) #define RV_GET_MINOR_VER(x) (((x) >> 20) & 0xFF) diff --git a/libavcodec/rv20enc.c b/libavcodec/rv20enc.c index 4462bde01d..dcb192f4bd 100644 --- a/libavcodec/rv20enc.c +++ b/libavcodec/rv20enc.c @@ -26,6 +26,7 @@ */ #include "mpegvideo.h" +#include "mpegvideodata.h" #include "h263.h" #include "put_bits.h"