aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAurelien Jacobs <aurel@gnuage.org>2007-07-10 20:23:08 +0000
committerAurelien Jacobs <aurel@gnuage.org>2007-07-10 20:23:08 +0000
commiteb75a69818c15272e94de9aba8e87a2c3535437a (patch)
tree0abc4ce94139bf1d1e0dbdac6c7001ee5f3052f8
parentf79488d426c3ac442b250ec1643a19d011f8594a (diff)
downloadffmpeg-eb75a69818c15272e94de9aba8e87a2c3535437a.tar.gz
Avoid linking with h263.c functions when the relevant codecs
are not compiled in. Originally committed as revision 9581 to svn://svn.ffmpeg.org/ffmpeg/trunk
-rw-r--r--libavcodec/dsputil.c3
-rw-r--r--libavcodec/h263.h46
-rw-r--r--libavcodec/i386/dsputil_mmx.c3
-rw-r--r--libavcodec/mpegvideo_enc.c47
-rw-r--r--libavcodec/msmpeg4.h2
5 files changed, 86 insertions, 15 deletions
diff --git a/libavcodec/dsputil.c b/libavcodec/dsputil.c
index 87435caa81..40f0339436 100644
--- a/libavcodec/dsputil.c
+++ b/libavcodec/dsputil.c
@@ -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 @@ void dsputil_init(DSPContext* c, AVCodecContext *avctx)
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;
diff --git a/libavcodec/h263.h b/libavcodec/h263.h
new file mode 100644
index 0000000000..2df3be5ab0
--- /dev/null
+++ b/libavcodec/h263.h
@@ -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 */
diff --git a/libavcodec/i386/dsputil_mmx.c b/libavcodec/i386/dsputil_mmx.c
index b9b365869a..333356832b 100644
--- a/libavcodec/i386/dsputil_mmx.c
+++ b/libavcodec/i386/dsputil_mmx.c
@@ -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 @@ void dsputil_init_mmx(DSPContext* c, AVCodecContext *avctx)
#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;
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index f7d6896940..e184d06105 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -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 @@ int MPV_encode_init(AVCodecContext *avctx)
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 @@ int MPV_encode_init(AVCodecContext *avctx)
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 @@ int MPV_encode_init(AVCodecContext *avctx)
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 @@ int MPV_encode_init(AVCodecContext *avctx)
/* 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 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x,
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 @@ static av_always_inline void encode_mb_internal(MpegEncContext *s, int motion_x,
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 int mb_var_thread(AVCodecContext *c, void *arg){
}
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 @@ static int encode_thread(AVCodecContext *c, void *arg){
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 @@ static int encode_thread(AVCodecContext *c, void *arg){
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 @@ static int encode_thread(AVCodecContext *c, void *arg){
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 @@ static int encode_thread(AVCodecContext *c, void *arg){
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 @@ static int encode_thread(AVCodecContext *c, void *arg){
}
}
}
- 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 @@ static int encode_thread(AVCodecContext *c, void *arg){
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 @@ static int encode_thread(AVCodecContext *c, void *arg){
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 @@ static int encode_thread(AVCodecContext *c, void *arg){
}
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 @@ static int encode_thread(AVCodecContext *c, void *arg){
}
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 @@ static int encode_thread(AVCodecContext *c, void *arg){
// 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 @@ static int encode_thread(AVCodecContext *c, void *arg){
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 @@ static int estimate_qp(MpegEncContext *s, int dry_run){
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 @@ static int encode_picture(MpegEncContext *s, int picture_number)
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:
diff --git a/libavcodec/msmpeg4.h b/libavcodec/msmpeg4.h
index 1cf9663260..1b2dabdb29 100644
--- a/libavcodec/msmpeg4.h
+++ b/libavcodec/msmpeg4.h
@@ -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 */