00001 /* 00002 * MPEG1/2 common code 00003 * Copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.org> 00004 * 00005 * This file is part of FFmpeg. 00006 * 00007 * FFmpeg is free software; you can redistribute it and/or 00008 * modify it under the terms of the GNU Lesser General Public 00009 * License as published by the Free Software Foundation; either 00010 * version 2.1 of the License, or (at your option) any later version. 00011 * 00012 * FFmpeg is distributed in the hope that it will be useful, 00013 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00014 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00015 * Lesser General Public License for more details. 00016 * 00017 * You should have received a copy of the GNU Lesser General Public 00018 * License along with FFmpeg; if not, write to the Free Software 00019 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 00020 */ 00021 00022 #ifndef AVCODEC_MPEG12_H 00023 #define AVCODEC_MPEG12_H 00024 00025 #include "mpegvideo.h" 00026 00027 #define DC_VLC_BITS 9 00028 #define TEX_VLC_BITS 9 00029 00030 extern VLC ff_dc_lum_vlc; 00031 extern VLC ff_dc_chroma_vlc; 00032 00033 typedef struct Mpeg1Context { 00034 MpegEncContext mpeg_enc_ctx; 00035 int mpeg_enc_ctx_allocated; /* true if decoding context allocated */ 00036 int repeat_field; /* true if we must repeat the field */ 00037 AVPanScan pan_scan; 00038 int slice_count; 00039 int swap_uv;//indicate VCR2 00040 int save_aspect_info; 00041 int save_width, save_height, save_progressive_seq; 00042 AVRational frame_rate_ext; 00043 int sync; 00044 int tmpgexs; 00045 } Mpeg1Context; 00046 00047 extern uint8_t ff_mpeg12_static_rl_table_store[2][2][2*MAX_RUN + MAX_LEVEL + 3]; 00048 00049 void ff_mpeg12_common_init(MpegEncContext *s); 00050 void ff_mpeg12_init_vlcs(void); 00051 00052 static inline int decode_dc(GetBitContext *gb, int component) 00053 { 00054 int code, diff; 00055 00056 if (component == 0) { 00057 code = get_vlc2(gb, ff_dc_lum_vlc.table, DC_VLC_BITS, 2); 00058 } else { 00059 code = get_vlc2(gb, ff_dc_chroma_vlc.table, DC_VLC_BITS, 2); 00060 } 00061 if (code < 0){ 00062 av_log(NULL, AV_LOG_ERROR, "invalid dc code at\n"); 00063 return 0xffff; 00064 } 00065 if (code == 0) { 00066 diff = 0; 00067 } else { 00068 diff = get_xbits(gb, code); 00069 } 00070 return diff; 00071 } 00072 00073 extern int ff_mpeg1_decode_block_intra(MpegEncContext *s, DCTELEM *block, int n); 00074 00075 #endif /* AVCODEC_MPEG12_H */