Mercurial > libavcodec.hg
changeset 5277:7b3fcb7c61ce libavcodec
Avoid linking with h263.c functions when the relevant codecs
are not compiled in.
author | aurel |
---|---|
date | Tue, 10 Jul 2007 20:23:08 +0000 |
parents | 0d71d658b19f |
children | ef85411bb7e8 |
files | dsputil.c h263.h i386/dsputil_mmx.c mpegvideo_enc.c msmpeg4.h |
diffstat | 5 files changed, 86 insertions(+), 15 deletions(-) [+] |
line wrap: on
line diff
--- a/dsputil.c Tue Jul 10 17:50:44 2007 +0000 +++ b/dsputil.c Tue Jul 10 20:23:08 2007 +0000 @@ -32,6 +32,7 @@ #include "mpegvideo.h" #include "simple_idct.h" #include "faandct.h" +#include "h263.h" #include "snow.h" /* snow.c */ @@ -4107,8 +4108,10 @@ c->h264_h_loop_filter_chroma_intra= h264_h_loop_filter_chroma_intra_c; c->h264_loop_filter_strength= NULL; + if (ENABLE_ANY_H263) { c->h263_h_loop_filter= h263_h_loop_filter_c; c->h263_v_loop_filter= h263_v_loop_filter_c; + } c->h261_loop_filter= h261_loop_filter_c;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/h263.h Tue Jul 10 20:23:08 2007 +0000 @@ -0,0 +1,46 @@ +/* + * H263/MPEG4 backend for ffmpeg encoder and decoder + * copyright (c) 2007 Aurelien Jacobs <aurel@gnuage.org> + * + * This file is part of FFmpeg. + * + * FFmpeg 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. + * + * FFmpeg 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 FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#ifndef AVCODEC_H263_H +#define AVCODEC_H263_H + +#include "config.h" +#include "msmpeg4.h" + +#define ENABLE_ANY_H263_DECODER (ENABLE_H263_DECODER || \ + ENABLE_H263I_DECODER || \ + ENABLE_FLV_DECODER || \ + ENABLE_RV10_DECODER || \ + ENABLE_RV20_DECODER || \ + ENABLE_MPEG4_DECODER || \ + ENABLE_MSMPEG4_DECODER || \ + ENABLE_WMV_DECODER) +#define ENABLE_ANY_H263_ENCODER (ENABLE_H263_ENCODER || \ + ENABLE_H263P_ENCODER || \ + ENABLE_FLV_ENCODER || \ + ENABLE_RV10_ENCODER || \ + ENABLE_RV20_ENCODER || \ + ENABLE_MPEG4_ENCODER || \ + ENABLE_MSMPEG4_ENCODER || \ + ENABLE_WMV_ENCODER) +#define ENABLE_ANY_H263 (ENABLE_ANY_H263_DECODER || ENABLE_ANY_H263_ENCODER) + +#endif /* AVCODEC_H263_H */
--- a/i386/dsputil_mmx.c Tue Jul 10 17:50:44 2007 +0000 +++ b/i386/dsputil_mmx.c Tue Jul 10 20:23:08 2007 +0000 @@ -29,6 +29,7 @@ #include "mmx.h" #include "vp3dsp_mmx.h" #include "vp3dsp_sse2.h" +#include "h263.h" //#undef NDEBUG //#include <assert.h> @@ -3347,8 +3348,10 @@ #endif //CONFIG_ENCODERS + if (ENABLE_ANY_H263) { c->h263_v_loop_filter= h263_v_loop_filter_mmx; c->h263_h_loop_filter= h263_h_loop_filter_mmx; + } c->put_h264_chroma_pixels_tab[0]= put_h264_chroma_mc8_mmx; c->put_h264_chroma_pixels_tab[1]= put_h264_chroma_mc4_mmx;
--- a/mpegvideo_enc.c Tue Jul 10 17:50:44 2007 +0000 +++ b/mpegvideo_enc.c Tue Jul 10 20:23:08 2007 +0000 @@ -33,6 +33,7 @@ #include "mpegvideo_common.h" #include "mjpegenc.h" #include "msmpeg4.h" +#include "h263.h" #include "faandct.h" #include <limits.h> @@ -543,6 +544,7 @@ s->low_delay=1; break; case CODEC_ID_H263: + if (!ENABLE_H263_ENCODER) return -1; if (h263_get_picture_format(s->width, s->height) == 7) { av_log(avctx, AV_LOG_INFO, "The specified picture size of %dx%d is not valid for the H.263 codec.\nValid sizes are 128x96, 176x144, 352x288, 704x576, and 1408x1152. Try H.263+.\n", s->width, s->height); return -1; @@ -668,7 +670,7 @@ if(s->flags & CODEC_FLAG_TRELLIS_QUANT) s->dct_quantize = dct_quantize_trellis_c; - if(s->modified_quant) + if((ENABLE_H263P_ENCODER || ENABLE_RV20_ENCODER) && s->modified_quant) s->chroma_qscale_table= ff_h263_chroma_qscale_table; s->progressive_frame= s->progressive_sequence= !(avctx->flags & (CODEC_FLAG_INTERLACED_DCT|CODEC_FLAG_INTERLACED_ME|CODEC_FLAG_ALT_SCAN)); @@ -679,7 +681,7 @@ if (ENABLE_H261_ENCODER && s->out_format == FMT_H261) ff_h261_encode_init(s); - if (s->out_format == FMT_H263) + if (ENABLE_ANY_H263_ENCODER && s->out_format == FMT_H263) h263_encode_init(s); if (ENABLE_MSMPEG4_ENCODER && s->msmpeg4_version) ff_msmpeg4_encode_init(s); @@ -690,7 +692,7 @@ /* init q matrix */ for(i=0;i<64;i++) { int j= s->dsp.idct_permutation[i]; - if(s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){ + if(ENABLE_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4 && s->mpeg_quant){ s->intra_matrix[j] = ff_mpeg4_default_intra_matrix[i]; s->inter_matrix[j] = ff_mpeg4_default_non_intra_matrix[i]; }else if(s->out_format == FMT_H263 || s->out_format == FMT_H261){ @@ -1698,6 +1700,7 @@ mpeg1_encode_mb(s, s->block, motion_x, motion_y); break; case CODEC_ID_MPEG4: + if (ENABLE_MPEG4_ENCODER) mpeg4_encode_mb(s, s->block, motion_x, motion_y); break; case CODEC_ID_MSMPEG4V2: case CODEC_ID_MSMPEG4V3: @@ -1718,6 +1721,8 @@ case CODEC_ID_FLV1: case CODEC_ID_RV10: case CODEC_ID_RV20: + if (ENABLE_H263_ENCODER || ENABLE_H263P_ENCODER || + ENABLE_FLV_ENCODER || ENABLE_RV10_ENCODER || ENABLE_RV20_ENCODER) h263_encode_mb(s, s->block, motion_x, motion_y); break; case CODEC_ID_MJPEG: if (ENABLE_MJPEG_ENCODER) @@ -1963,7 +1968,7 @@ } static void write_slice_end(MpegEncContext *s){ - if(s->codec_id==CODEC_ID_MPEG4){ + if(ENABLE_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4){ if(s->partitioned_frame){ ff_mpeg4_merge_partitions(s); } @@ -2025,10 +2030,11 @@ case CODEC_ID_H263: case CODEC_ID_H263P: case CODEC_ID_FLV1: + if (ENABLE_H263_ENCODER || ENABLE_H263P_ENCODER || ENABLE_FLV_ENCODER) s->gob_index = ff_h263_get_gob_height(s); break; case CODEC_ID_MPEG4: - if(s->partitioned_frame) + if(ENABLE_MPEG4_ENCODER && s->partitioned_frame) ff_mpeg4_init_partitions(s); break; } @@ -2101,7 +2107,7 @@ if(s->start_mb_y != mb_y || mb_x!=0){ write_slice_end(s); - if(s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame){ + if(ENABLE_MPEG4_ENCODER && s->codec_id==CODEC_ID_MPEG4 && s->partitioned_frame){ ff_mpeg4_init_partitions(s); } } @@ -2128,8 +2134,10 @@ switch(s->codec_id){ case CODEC_ID_MPEG4: + if (ENABLE_MPEG4_ENCODER) { ff_mpeg4_encode_video_packet_header(s); ff_mpeg4_clean_buffers(s); + } break; case CODEC_ID_MPEG1VIDEO: case CODEC_ID_MPEG2VIDEO: @@ -2140,6 +2148,7 @@ break; case CODEC_ID_H263: case CODEC_ID_H263P: + if (ENABLE_H263_ENCODER || ENABLE_H263P_ENCODER) h263_encode_gob_header(s, mb_y); break; } @@ -2348,7 +2357,7 @@ } } } - if(mb_type&CANDIDATE_MB_TYPE_DIRECT){ + if(ENABLE_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT){ int mx= s->b_direct_mv_table[xy][0]; int my= s->b_direct_mv_table[xy][1]; @@ -2359,7 +2368,7 @@ encode_mb_hq(s, &backup_s, &best_s, CANDIDATE_MB_TYPE_DIRECT, pb, pb2, tex_pb, &dmin, &next_block, mx, my); } - if(mb_type&CANDIDATE_MB_TYPE_DIRECT0){ + if(ENABLE_MPEG4_ENCODER && mb_type&CANDIDATE_MB_TYPE_DIRECT0){ backup_s.dquant = 0; s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; s->mb_intra= 0; @@ -2374,7 +2383,7 @@ if(coded){ int mx,my; memcpy(s->mv, best_s.mv, sizeof(s->mv)); - if(best_s.mv_dir & MV_DIRECT){ + if(ENABLE_MPEG4_ENCODER && best_s.mv_dir & MV_DIRECT){ mx=my=0; //FIXME find the one we actually used ff_mpeg4_set_direct_mv(s, mx, my); }else if(best_s.mv_dir&MV_DIR_BACKWARD){ @@ -2422,7 +2431,8 @@ } s->last_bits= put_bits_count(&s->pb); - if (s->out_format == FMT_H263 && s->pict_type!=B_TYPE) + if (ENABLE_ANY_H263_ENCODER && + s->out_format == FMT_H263 && s->pict_type!=B_TYPE) ff_h263_update_motion_val(s); if(next_block==0){ //FIXME 16 vs linesize16 @@ -2471,16 +2481,20 @@ } break; case CANDIDATE_MB_TYPE_DIRECT: + if (ENABLE_MPEG4_ENCODER) { s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; s->mb_intra= 0; motion_x=s->b_direct_mv_table[xy][0]; motion_y=s->b_direct_mv_table[xy][1]; ff_mpeg4_set_direct_mv(s, motion_x, motion_y); + } break; case CANDIDATE_MB_TYPE_DIRECT0: + if (ENABLE_MPEG4_ENCODER) { s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD | MV_DIRECT; s->mb_intra= 0; ff_mpeg4_set_direct_mv(s, 0, 0); + } break; case CANDIDATE_MB_TYPE_BIDIR: s->mv_dir = MV_DIR_FORWARD | MV_DIR_BACKWARD; @@ -2544,7 +2558,8 @@ // RAL: Update last macroblock type s->last_mv_dir = s->mv_dir; - if (s->out_format == FMT_H263 && s->pict_type!=B_TYPE) + if (ENABLE_ANY_H263_ENCODER && + s->out_format == FMT_H263 && s->pict_type!=B_TYPE) ff_h263_update_motion_val(s); MPV_decode_mb(s, s->block); @@ -2574,7 +2589,7 @@ s->dest[2], w>>1, h>>1, s->uvlinesize); } if(s->loop_filter){ - if(s->out_format == FMT_H263) + if(ENABLE_ANY_H263_ENCODER && s->out_format == FMT_H263) ff_h263_loop_filter(s); } //printf("MB %d %d bits\n", s->mb_x+s->mb_y*s->mb_stride, put_bits_count(&s->pb)); @@ -2653,11 +2668,13 @@ if(s->adaptive_quant){ switch(s->codec_id){ case CODEC_ID_MPEG4: + if (ENABLE_MPEG4_ENCODER) ff_clean_mpeg4_qscales(s); break; case CODEC_ID_H263: case CODEC_ID_H263P: case CODEC_ID_FLV1: + if (ENABLE_H263_ENCODER||ENABLE_H263P_ENCODER||ENABLE_FLV_ENCODER) ff_clean_h263_qscales(s); break; } @@ -2867,15 +2884,15 @@ ff_wmv2_encode_picture_header(s, picture_number); else if (ENABLE_MSMPEG4_ENCODER && s->h263_msmpeg4) msmpeg4_encode_picture_header(s, picture_number); - else if (s->h263_pred) + else if (ENABLE_MPEG4_ENCODER && s->h263_pred) mpeg4_encode_picture_header(s, picture_number); else if (ENABLE_RV10_ENCODER && s->codec_id == CODEC_ID_RV10) rv10_encode_picture_header(s, picture_number); else if (ENABLE_RV20_ENCODER && s->codec_id == CODEC_ID_RV20) rv20_encode_picture_header(s, picture_number); - else if (s->codec_id == CODEC_ID_FLV1) + else if (ENABLE_FLV_ENCODER && s->codec_id == CODEC_ID_FLV1) ff_flv_encode_picture_header(s, picture_number); - else + else if (ENABLE_ANY_H263_ENCODER) h263_encode_picture_header(s, picture_number); break; case FMT_MPEG1:
--- a/msmpeg4.h Tue Jul 10 17:50:44 2007 +0000 +++ b/msmpeg4.h Tue Jul 10 20:23:08 2007 +0000 @@ -38,5 +38,7 @@ ENABLE_WMV2_ENCODER) #define ENABLE_MSMPEG4 (ENABLE_MSMPEG4_DECODER || ENABLE_MSMPEG4_ENCODER) #define ENABLE_WMV2 (ENABLE_WMV2_DECODER || ENABLE_WMV2_ENCODER) +#define ENABLE_WMV_DECODER (ENABLE_WMV1_DECODER || ENABLE_WMV2_DECODER) +#define ENABLE_WMV_ENCODER (ENABLE_WMV1_ENCODER || ENABLE_WMV2_ENCODER) #endif /* MSMPEG4_H */