From dc25d79f4980fb547908f4dd43732ebc0622610c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 5 Jun 2011 01:28:22 +0200 Subject: Drop unnecessary directory prefixes from #include directives. --- libavcodec/aac_tablegen.h | 2 +- libavcodec/dnxhdenc.h | 5 +++-- libavcodec/mlpdsp.c | 2 +- libavcodec/v210enc.c | 2 +- libavformat/mmsh.c | 2 +- libavutil/audioconvert.c | 4 ++-- libavutil/eval.c | 2 +- libavutil/imgutils.c | 2 +- libavutil/imgutils.h | 2 +- libavutil/parseutils.c | 9 +++++---- libavutil/parseutils.h | 2 +- 11 files changed, 18 insertions(+), 16 deletions(-) diff --git a/libavcodec/aac_tablegen.h b/libavcodec/aac_tablegen.h index 4486e1a9fc..8773d9b975 100644 --- a/libavcodec/aac_tablegen.h +++ b/libavcodec/aac_tablegen.h @@ -29,7 +29,7 @@ #include "libavcodec/aac_tables.h" #else #include "libavutil/mathematics.h" -#include "libavcodec/aac.h" +#include "aac.h" float ff_aac_pow2sf_tab[428]; void ff_aac_tableinit(void) diff --git a/libavcodec/dnxhdenc.h b/libavcodec/dnxhdenc.h index 43f65e46dd..bb24540a9f 100644 --- a/libavcodec/dnxhdenc.h +++ b/libavcodec/dnxhdenc.h @@ -25,8 +25,9 @@ #define AVCODEC_DNXHDENC_H #include -#include "libavcodec/mpegvideo.h" -#include "libavcodec/dnxhddata.h" + +#include "mpegvideo.h" +#include "dnxhddata.h" typedef struct { uint16_t mb; diff --git a/libavcodec/mlpdsp.c b/libavcodec/mlpdsp.c index 0053df88d8..7d01c7586d 100644 --- a/libavcodec/mlpdsp.c +++ b/libavcodec/mlpdsp.c @@ -19,8 +19,8 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavcodec/mlp.h" #include "dsputil.h" +#include "mlp.h" static void ff_mlp_filter_channel(int32_t *state, const int32_t *coeff, int firorder, int iirorder, diff --git a/libavcodec/v210enc.c b/libavcodec/v210enc.c index dcaaac0dc5..8b022fa8f8 100644 --- a/libavcodec/v210enc.c +++ b/libavcodec/v210enc.c @@ -22,7 +22,7 @@ */ #include "avcodec.h" -#include "libavcodec/bytestream.h" +#include "bytestream.h" static av_cold int encode_init(AVCodecContext *avctx) { diff --git a/libavformat/mmsh.c b/libavformat/mmsh.c index 203691e2fc..b19973ea76 100644 --- a/libavformat/mmsh.c +++ b/libavformat/mmsh.c @@ -28,7 +28,7 @@ #include #include "libavutil/intreadwrite.h" #include "libavutil/avstring.h" -#include "libavformat/internal.h" +#include "internal.h" #include "mms.h" #include "asf.h" #include "http.h" diff --git a/libavutil/audioconvert.c b/libavutil/audioconvert.c index f789c77e20..fa27f0168b 100644 --- a/libavutil/audioconvert.c +++ b/libavutil/audioconvert.c @@ -23,8 +23,8 @@ * audio conversion routines */ -#include "libavutil/avutil.h" -#include "libavutil/avstring.h" +#include "avstring.h" +#include "avutil.h" #include "audioconvert.h" static const char * const channel_names[] = { diff --git a/libavutil/eval.c b/libavutil/eval.c index a6a59a39ef..a3788210e3 100644 --- a/libavutil/eval.c +++ b/libavutil/eval.c @@ -26,7 +26,7 @@ * see http://joe.hotchkiss.com/programming/eval/eval.html */ -#include "libavutil/avutil.h" +#include "avutil.h" #include "eval.h" typedef struct Parser { diff --git a/libavutil/imgutils.c b/libavutil/imgutils.c index 544007f120..46853cafcb 100644 --- a/libavutil/imgutils.c +++ b/libavutil/imgutils.c @@ -23,7 +23,7 @@ #include "imgutils.h" #include "internal.h" -#include "libavutil/pixdesc.h" +#include "pixdesc.h" void av_image_fill_max_pixsteps(int max_pixsteps[4], int max_pixstep_comps[4], const AVPixFmtDescriptor *pixdesc) diff --git a/libavutil/imgutils.h b/libavutil/imgutils.h index 7abeb657fb..b569eb1ca4 100644 --- a/libavutil/imgutils.h +++ b/libavutil/imgutils.h @@ -24,8 +24,8 @@ * misc image utilities */ -#include "libavutil/pixdesc.h" #include "avutil.h" +#include "pixdesc.h" /** * Compute the max pixel step for each plane of an image with a diff --git a/libavutil/parseutils.c b/libavutil/parseutils.c index cc901314d9..0272c3ef67 100644 --- a/libavutil/parseutils.c +++ b/libavutil/parseutils.c @@ -24,11 +24,12 @@ #include #include #include + +#include "avstring.h" +#include "avutil.h" +#include "eval.h" +#include "random_seed.h" #include "parseutils.h" -#include "libavutil/avutil.h" -#include "libavutil/eval.h" -#include "libavutil/avstring.h" -#include "libavutil/random_seed.h" typedef struct { const char *abbr; diff --git a/libavutil/parseutils.h b/libavutil/parseutils.h index c0f9aec392..befbbb56a1 100644 --- a/libavutil/parseutils.h +++ b/libavutil/parseutils.h @@ -19,7 +19,7 @@ #ifndef AVUTIL_PARSEUTILS_H #define AVUTIL_PARSEUTILS_H -#include "libavutil/rational.h" +#include "rational.h" /** * @file -- cgit v1.2.3 From e01bb264e78385367b716a55df713ae1a6750310 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 5 Jun 2011 15:27:51 +0200 Subject: inverse.c: Replace unnecessary intmath.h header by necessary stdint.h. --- libavutil/inverse.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libavutil/inverse.c b/libavutil/inverse.c index bca61832ef..5a5c490e0a 100644 --- a/libavutil/inverse.c +++ b/libavutil/inverse.c @@ -19,7 +19,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -#include "libavutil/intmath.h" +#include /* a*inverse[b]>>32 == a/b for all 0<=a<=16909558 && 2<=b<=256 * for a>16909558, is an overestimate by less than 1 part in 1<<24 */ -- cgit v1.2.3 From d7cf5639e727b454896e7d7d8da2abcd4b631eac Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 6 Jun 2011 00:39:39 +0200 Subject: Replace some printf instances in debug code by av_log. --- libavformat/avidec.c | 4 ++-- libavformat/mpeg.c | 5 +++-- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/libavformat/avidec.c b/libavformat/avidec.c index ff270edae5..dd2d1d0da6 100644 --- a/libavformat/avidec.c +++ b/libavformat/avidec.c @@ -1206,7 +1206,7 @@ static int avi_load_index(AVFormatContext *s) if (avio_seek(pb, avi->movi_end, SEEK_SET) < 0) goto the_end; // maybe truncated file #ifdef DEBUG_SEEK - printf("movi_end=0x%"PRIx64"\n", avi->movi_end); + av_log(s, AV_LOG_DEBUG, "movi_end=0x%"PRIx64"\n", avi->movi_end); #endif for(;;) { if (pb->eof_reached) @@ -1214,7 +1214,7 @@ static int avi_load_index(AVFormatContext *s) tag = avio_rl32(pb); size = avio_rl32(pb); #ifdef DEBUG_SEEK - printf("tag=%c%c%c%c size=0x%x\n", + av_log(s, AV_LOG_DEBUG, "tag=%c%c%c%c size=0x%x\n", tag & 0xff, (tag >> 8) & 0xff, (tag >> 16) & 0xff, diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 98506612cd..86cee0c4b8 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -593,7 +593,7 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, len = mpegps_read_pes_header(s, &pos, &startcode, &pts, &dts); if (len < 0) { #ifdef DEBUG_SEEK - printf("none (ret=%d)\n", len); + av_log(s, AV_LOG_DEBUG, "none (ret=%d)\n", len); #endif return AV_NOPTS_VALUE; } @@ -604,7 +604,8 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, avio_skip(s->pb, len); } #ifdef DEBUG_SEEK - printf("pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n", pos, dts, dts / 90000.0); + av_log(s, AV_LOG_DEBUG, "pos=0x%"PRIx64" dts=0x%"PRIx64" %0.3f\n", + pos, dts, dts / 90000.0); #endif *ppos = pos; return dts; -- cgit v1.2.3 From f8ea0eb6ff5719a3ff2a60454dd0a2b07aa6dbe2 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 6 Jun 2011 00:52:28 +0200 Subject: svq1dec: Fix debug statements that referenced non-existing context. --- libavcodec/svq1dec.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c index fc36bc3489..2a80374569 100644 --- a/libavcodec/svq1dec.c +++ b/libavcodec/svq1dec.c @@ -237,7 +237,7 @@ static int svq1_decode_block_intra (GetBitContext *bitbuf, uint8_t *pixels, int } if ((stages > 0) && (level >= 4)) { - av_dlog(s->avctx, + av_dlog(NULL, "Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n", stages, level); return -1; /* invalid vector */ @@ -287,7 +287,7 @@ static int svq1_decode_block_non_intra (GetBitContext *bitbuf, uint8_t *pixels, if (stages == -1) continue; /* skip vector */ if ((stages > 0) && (level >= 4)) { - av_dlog(s->avctx, + av_dlog(NULL, "Error (svq1_decode_block_non_intra): invalid vector: stages=%i level=%i\n", stages, level); return -1; /* invalid vector */ -- cgit v1.2.3 From 1f6b9cc31d086860c7a7887685bed321fe3843f4 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 6 Jun 2011 00:53:31 +0200 Subject: Replace some nonstandard DEBUG_* preprocessor directives by plain DEBUG. --- ffplay.c | 5 +---- libavcodec/dvbsubdec.c | 7 +++---- libavcodec/ppc/h264_template_altivec.c | 3 +-- libavformat/rtspdec.c | 7 ------- 4 files changed, 5 insertions(+), 17 deletions(-) diff --git a/ffplay.c b/ffplay.c index e036bbdf94..4ccad0618d 100644 --- a/ffplay.c +++ b/ffplay.c @@ -56,9 +56,6 @@ const char program_name[] = "ffplay"; const int program_birth_year = 2003; -//#define DEBUG -//#define DEBUG_SYNC - #define MAX_QUEUE_SIZE (15 * 1024 * 1024) #define MIN_AUDIOQ_SIZE (20 * 16 * 1024) #define MIN_FRAMES 5 @@ -2056,7 +2053,7 @@ static int audio_decode_frame(VideoState *is, double *pts_ptr) n = 2 * dec->channels; is->audio_clock += (double)data_size / (double)(n * dec->sample_rate); -#if defined(DEBUG_SYNC) +#ifdef DEBUG { static double last_clock; printf("audio: delay=%0.3f clock=%0.3f pts=%0.3f\n", diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index 2c27f6b527..b6b57b8915 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -26,7 +26,6 @@ //#define DEBUG //#define DEBUG_PACKET_CONTENTS -//#define DEBUG_SAVE_IMAGES #define DVBSUB_PAGE_SEGMENT 0x10 #define DVBSUB_REGION_SEGMENT 0x11 @@ -37,7 +36,7 @@ #define cm (ff_cropTbl + MAX_NEG_CROP) -#ifdef DEBUG_SAVE_IMAGES +#ifdef DEBUG #undef fprintf #if 0 static void png_save(const char *filename, uint8_t *bitmap, int w, int h, @@ -1174,7 +1173,7 @@ static void dvbsub_parse_page_segment(AVCodecContext *avctx, } -#ifdef DEBUG_SAVE_IMAGES +#ifdef DEBUG static void save_display_set(DVBSubContext *ctx) { DVBSubRegion *region; @@ -1387,7 +1386,7 @@ static int dvbsub_display_end_segment(AVCodecContext *avctx, const uint8_t *buf, sub->num_rects = i; -#ifdef DEBUG_SAVE_IMAGES +#ifdef DEBUG save_display_set(ctx); #endif diff --git a/libavcodec/ppc/h264_template_altivec.c b/libavcodec/ppc/h264_template_altivec.c index 020d7c7023..2a8f4bf672 100644 --- a/libavcodec/ppc/h264_template_altivec.c +++ b/libavcodec/ppc/h264_template_altivec.c @@ -18,8 +18,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ -//#define DEBUG_ALIGNMENT -#ifdef DEBUG_ALIGNMENT +#ifdef DEBUG #define ASSERT_ALIGNED(ptr) assert(((unsigned long)ptr&0x0000000F)); #else #define ASSERT_ALIGNED(ptr) ; diff --git a/libavformat/rtspdec.c b/libavformat/rtspdec.c index fa6bc05517..9cd9be1d4b 100644 --- a/libavformat/rtspdec.c +++ b/libavformat/rtspdec.c @@ -31,9 +31,6 @@ #include "rdt.h" #include "url.h" -//#define DEBUG -//#define DEBUG_RTP_TCP - static int rtsp_read_play(AVFormatContext *s) { RTSPState *rt = s->priv_data; @@ -191,9 +188,7 @@ int ff_rtsp_tcp_read_packet(AVFormatContext *s, RTSPStream **prtsp_st, int id, len, i, ret; RTSPStream *rtsp_st; -#ifdef DEBUG_RTP_TCP av_dlog(s, "tcp_read_packet:\n"); -#endif redo: for (;;) { RTSPMessageHeader reply; @@ -212,9 +207,7 @@ redo: return -1; id = buf[0]; len = AV_RB16(buf + 1); -#ifdef DEBUG_RTP_TCP av_dlog(s, "id=%d len=%d\n", id, len); -#endif if (len > buf_size || len < 12) goto redo; /* get the data */ -- cgit v1.2.3 From 02a8d43adf7063bda2d20039d3e9b19d8469fe69 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 6 Jun 2011 01:25:32 +0200 Subject: Replace some av_log/printf + #ifdef combinations by av_dlog. --- libavcodec/bitstream.c | 26 ++++++-------------------- libavcodec/dv.c | 28 +++++++--------------------- libavcodec/dvbsub_parser.c | 16 ++++------------ libavcodec/dvbsubdec.c | 41 +++++++++++++---------------------------- libavcodec/pgssubdec.c | 13 ++++--------- libavformat/mov.c | 9 +++------ 6 files changed, 37 insertions(+), 96 deletions(-) diff --git a/libavcodec/bitstream.c b/libavcodec/bitstream.c index 329ec9527e..97d5b49105 100644 --- a/libavcodec/bitstream.c +++ b/libavcodec/bitstream.c @@ -81,8 +81,6 @@ void ff_copy_bits(PutBitContext *pb, const uint8_t *src, int length) /* VLC decoding */ -//#define DEBUG_VLC - #define GET_DATA(v, table, i, wrap, size) \ {\ const uint8_t *ptr = (const uint8_t *)table + i * wrap;\ @@ -162,10 +160,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, table_size = 1 << table_nb_bits; table_index = alloc_table(vlc, table_size, flags & INIT_VLC_USE_NEW_STATIC); -#ifdef DEBUG_VLC - av_log(NULL,AV_LOG_DEBUG,"new table index=%d size=%d\n", - table_index, table_size); -#endif + av_dlog(NULL, "new table index=%d size=%d\n", table_index, table_size); if (table_index < 0) return -1; table = &vlc->table[table_index]; @@ -180,9 +175,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, n = codes[i].bits; code = codes[i].code; symbol = codes[i].symbol; -#if defined(DEBUG_VLC) && 0 - av_log(NULL,AV_LOG_DEBUG,"i=%d n=%d code=0x%x\n", i, n, code); -#endif + av_dlog(NULL, "i=%d n=%d code=0x%x\n", i, n, code); if (n <= table_nb_bits) { /* no need to add another table */ j = code >> (32 - table_nb_bits); @@ -193,10 +186,7 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, inc = 1 << n; } for (k = 0; k < nb; k++) { -#ifdef DEBUG_VLC - av_log(NULL, AV_LOG_DEBUG, "%4x: code=%d n=%d\n", - j, i, n); -#endif + av_dlog(NULL, "%4x: code=%d n=%d\n", j, i, n); if (table[j][1] /*bits*/ != 0) { av_log(NULL, AV_LOG_ERROR, "incorrect codes\n"); return -1; @@ -226,10 +216,8 @@ static int build_table(VLC *vlc, int table_nb_bits, int nb_codes, subtable_bits = FFMIN(subtable_bits, table_nb_bits); j = (flags & INIT_VLC_LE) ? bitswap_32(code_prefix) >> (32 - table_nb_bits) : code_prefix; table[j][1] = -subtable_bits; -#ifdef DEBUG_VLC - av_log(NULL,AV_LOG_DEBUG,"%4x: n=%d (subtable)\n", - j, codes[i].bits + table_nb_bits); -#endif + av_dlog(NULL, "%4x: n=%d (subtable)\n", + j, codes[i].bits + table_nb_bits); index = build_table(vlc, subtable_bits, k-i, codes+i, flags); if (index < 0) return -1; @@ -291,9 +279,7 @@ int init_vlc_sparse(VLC *vlc, int nb_bits, int nb_codes, vlc->table_size = 0; } -#ifdef DEBUG_VLC - av_log(NULL,AV_LOG_DEBUG,"build table nb_codes=%d\n", nb_codes); -#endif + av_dlog(NULL, "build table nb_codes=%d\n", nb_codes); buf = av_malloc((nb_codes+1)*sizeof(VLCcode)); diff --git a/libavcodec/dv.c b/libavcodec/dv.c index cd682ecb2b..4fde2a7899 100644 --- a/libavcodec/dv.c +++ b/libavcodec/dv.c @@ -358,9 +358,6 @@ static av_cold int dvvideo_init_encoder(AVCodecContext *avctx) return dvvideo_init(avctx); } -// #define VLC_DEBUG -// #define printf(...) av_log(NULL, AV_LOG_ERROR, __VA_ARGS__) - typedef struct BlockInfo { const uint32_t *factor_table; const uint8_t *scan_table; @@ -404,9 +401,8 @@ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block) /* get the AC coefficients until last_index is reached */ for (;;) { -#ifdef VLC_DEBUG - printf("%2d: bits=%04x index=%d\n", pos, SHOW_UBITS(re, gb, 16), re_index); -#endif + av_dlog(NULL, "%2d: bits=%04x index=%d\n", pos, SHOW_UBITS(re, gb, 16), + re_index); /* our own optimized GET_RL_VLC */ index = NEG_USR32(re_cache, TEX_VLC_BITS); vlc_len = dv_rl_vlc[index].len; @@ -427,9 +423,7 @@ static void dv_decode_ac(GetBitContext *gb, BlockInfo *mb, DCTELEM *block) } re_index += vlc_len; -#ifdef VLC_DEBUG - printf("run=%d level=%d\n", run, level); -#endif + av_dlog(NULL, "run=%d level=%d\n", run, level); pos += run; if (pos >= 64) break; @@ -533,9 +527,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) mb->pos = 0; mb->partial_bit_count = 0; -#ifdef VLC_DEBUG - printf("MB block: %d, %d ", mb_index, j); -#endif + av_dlog(avctx, "MB block: %d, %d ", mb_index, j); dv_decode_ac(&gb, mb, block); /* write the remaining bits in a new buffer only if the @@ -548,9 +540,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) } /* pass 2 : we can do it just after */ -#ifdef VLC_DEBUG - printf("***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index); -#endif + av_dlog(avctx, "***pass 2 size=%d MB#=%d\n", put_bits_count(&pb), mb_index); block = block1; mb = mb1; init_get_bits(&gb, mb_bit_buffer, put_bits_count(&pb)); @@ -570,9 +560,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) } /* we need a pass other the whole video segment */ -#ifdef VLC_DEBUG - printf("***pass 3 size=%d\n", put_bits_count(&vs_pb)); -#endif + av_dlog(avctx, "***pass 3 size=%d\n", put_bits_count(&vs_pb)); block = &sblock[0][0]; mb = mb_data; init_get_bits(&gb, vs_bit_buffer, put_bits_count(&vs_pb)); @@ -580,9 +568,7 @@ static int dv_decode_video_segment(AVCodecContext *avctx, void *arg) for (mb_index = 0; mb_index < 5; mb_index++) { for (j = 0; j < s->sys->bpm; j++) { if (mb->pos < 64) { -#ifdef VLC_DEBUG - printf("start %d:%d\n", mb_index, j); -#endif + av_dlog(avctx, "start %d:%d\n", mb_index, j); dv_decode_ac(&gb, mb, block); } if (mb->pos >= 64 && mb->pos < 127) diff --git a/libavcodec/dvbsub_parser.c b/libavcodec/dvbsub_parser.c index b54aac6b99..8f3b0653d4 100644 --- a/libavcodec/dvbsub_parser.c +++ b/libavcodec/dvbsub_parser.c @@ -22,9 +22,6 @@ #include "dsputil.h" #include "get_bits.h" -//#define DEBUG -//#define DEBUG_PACKET_CONTENTS - /* Parser (mostly) copied from dvdsub.c */ #define PARSE_BUF_SIZE (65536) @@ -53,25 +50,20 @@ static int dvbsub_parse(AVCodecParserContext *s, { DVBSubParseContext *pc = s->priv_data; uint8_t *p, *p_end; - int len, buf_pos = 0; + int i, len, buf_pos = 0; av_dlog(avctx, "DVB parse packet pts=%"PRIx64", lpts=%"PRIx64", cpts=%"PRIx64":\n", s->pts, s->last_pts, s->cur_frame_pts[s->cur_frame_start_index]); -#ifdef DEBUG_PACKET_CONTENTS - int i; - for (i=0; i < buf_size; i++) { - av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); + av_dlog(avctx, "%02x ", buf[i]); if (i % 16 == 15) - av_log(avctx, AV_LOG_INFO, "\n"); + av_dlog(avctx, "\n"); } if (i % 16 != 0) - av_log(avctx, AV_LOG_INFO, "\n"); - -#endif + av_dlog(avctx, "\n"); *poutbuf = NULL; *poutbuf_size = 0; diff --git a/libavcodec/dvbsubdec.c b/libavcodec/dvbsubdec.c index b6b57b8915..66659ae637 100644 --- a/libavcodec/dvbsubdec.c +++ b/libavcodec/dvbsubdec.c @@ -24,9 +24,6 @@ #include "bytestream.h" #include "libavutil/colorspace.h" -//#define DEBUG -//#define DEBUG_PACKET_CONTENTS - #define DVBSUB_PAGE_SEGMENT 0x10 #define DVBSUB_REGION_SEGMENT 0x11 #define DVBSUB_CLUT_SEGMENT 0x12 @@ -749,20 +746,17 @@ static void dvbsub_parse_pixel_data_block(AVCodecContext *avctx, DVBSubObjectDis av_dlog(avctx, "DVB pixel block size %d, %s field:\n", buf_size, top_bottom ? "bottom" : "top"); -#ifdef DEBUG_PACKET_CONTENTS for (i = 0; i < buf_size; i++) { if (i % 16 == 0) - av_log(avctx, AV_LOG_INFO, "0x%08p: ", buf+i); + av_dlog(avctx, "0x%8p: ", buf+i); - av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); + av_dlog(avctx, "%02x ", buf[i]); if (i % 16 == 15) - av_log(avctx, AV_LOG_INFO, "\n"); + av_dlog(avctx, "\n"); } if (i % 16) - av_log(avctx, AV_LOG_INFO, "\n"); - -#endif + av_dlog(avctx, "\n"); if (region == 0) return; @@ -911,27 +905,22 @@ static void dvbsub_parse_clut_segment(AVCodecContext *avctx, DVBSubContext *ctx = avctx->priv_data; const uint8_t *buf_end = buf + buf_size; - int clut_id; + int i, clut_id; DVBSubCLUT *clut; int entry_id, depth , full_range; int y, cr, cb, alpha; int r, g, b, r_add, g_add, b_add; -#ifdef DEBUG_PACKET_CONTENTS - int i; - - av_log(avctx, AV_LOG_INFO, "DVB clut packet:\n"); + av_dlog(avctx, "DVB clut packet:\n"); for (i=0; i < buf_size; i++) { - av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); + av_dlog(avctx, "%02x ", buf[i]); if (i % 16 == 15) - av_log(avctx, AV_LOG_INFO, "\n"); + av_dlog(avctx, "\n"); } if (i % 16) - av_log(avctx, AV_LOG_INFO, "\n"); - -#endif + av_dlog(avctx, "\n"); clut_id = *buf++; buf += 1; @@ -1405,22 +1394,18 @@ static int dvbsub_decode(AVCodecContext *avctx, int segment_type; int page_id; int segment_length; - -#ifdef DEBUG_PACKET_CONTENTS int i; - av_log(avctx, AV_LOG_INFO, "DVB sub packet:\n"); + av_dlog(avctx, "DVB sub packet:\n"); for (i=0; i < buf_size; i++) { - av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); + av_dlog(avctx, "%02x ", buf[i]); if (i % 16 == 15) - av_log(avctx, AV_LOG_INFO, "\n"); + av_dlog(avctx, "\n"); } if (i % 16) - av_log(avctx, AV_LOG_INFO, "\n"); - -#endif + av_dlog(avctx, "\n"); if (buf_size <= 6 || *buf != 0x0f) { av_dlog(avctx, "incomplete or broken packet"); diff --git a/libavcodec/pgssubdec.c b/libavcodec/pgssubdec.c index a480da1168..9546c38882 100644 --- a/libavcodec/pgssubdec.c +++ b/libavcodec/pgssubdec.c @@ -30,8 +30,6 @@ #include "libavutil/colorspace.h" #include "libavutil/imgutils.h" -//#define DEBUG_PACKET_CONTENTS - #define RGBA(r,g,b,a) (((a) << 24) | ((r) << 16) | ((g) << 8) | (b)) enum SegmentType { @@ -404,21 +402,18 @@ static int decode(AVCodecContext *avctx, void *data, int *data_size, const uint8_t *buf_end; uint8_t segment_type; int segment_length; - -#ifdef DEBUG_PACKET_CONTENTS int i; - av_log(avctx, AV_LOG_INFO, "PGS sub packet:\n"); + av_dlog(avctx, "PGS sub packet:\n"); for (i = 0; i < buf_size; i++) { - av_log(avctx, AV_LOG_INFO, "%02x ", buf[i]); + av_dlog(avctx, "%02x ", buf[i]); if (i % 16 == 15) - av_log(avctx, AV_LOG_INFO, "\n"); + av_dlog(avctx, "\n"); } if (i & 15) - av_log(avctx, AV_LOG_INFO, "\n"); -#endif + av_dlog(avctx, "\n"); *data_size = 0; diff --git a/libavformat/mov.c b/libavformat/mov.c index 6c3c95caa2..3aec86ceb1 100644 --- a/libavformat/mov.c +++ b/libavformat/mov.c @@ -23,7 +23,6 @@ #include //#define DEBUG -//#define DEBUG_METADATA //#define MOV_EXPORT_ALL_METADATA #include "libavutil/intreadwrite.h" @@ -210,11 +209,9 @@ static int mov_read_udta_string(MOVContext *c, AVIOContext *pb, MOVAtom atom) av_metadata_set2(&c->fc->metadata, key2, str, 0); } } -#ifdef DEBUG_METADATA - av_log(c->fc, AV_LOG_DEBUG, "lang \"%3s\" ", language); - av_log(c->fc, AV_LOG_DEBUG, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %lld\n", - key, str, (char*)&atom.type, str_size, atom.size); -#endif + av_dlog(c->fc, "lang \"%3s\" ", language); + av_dlog(c->fc, "tag \"%s\" value \"%s\" atom \"%.4s\" %d %"PRId64"\n", + key, str, (char*)&atom.type, str_size, atom.size); return 0; } -- cgit v1.2.3 From e8f6bd4b88405526dea26daaf86e94509e7144df Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Mon, 6 Jun 2011 13:32:37 +0200 Subject: configure: Document --enable-vdpau. The option is disabled by default, so enabling it should be documented. --- configure | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/configure b/configure index 34c1ed6d25..2a1883bfa0 100755 --- a/configure +++ b/configure @@ -107,7 +107,7 @@ Configuration options: --disable-mdct disable MDCT code --disable-rdft disable RDFT code --enable-vaapi enable VAAPI code - --disable-vdpau disable VDPAU code + --enable-vdpau enable VDPAU code --disable-dxva2 disable DXVA2 code --enable-runtime-cpudetect detect cpu capabilities at runtime (bigger binary) --enable-hardcoded-tables use hardcoded tables instead of runtime generation -- cgit v1.2.3 From 2d9570a304054c009b7f3fee60fff1299f25c7f5 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 7 Jun 2011 14:02:38 +0200 Subject: vorbisdec: Restore mistakenly removed debug output. --- libavcodec/vorbisdec.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c index b969d45783..017102e777 100644 --- a/libavcodec/vorbisdec.c +++ b/libavcodec/vorbisdec.c @@ -20,6 +20,7 @@ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA */ +#include #include #define ALT_BITSTREAM_READER_LE @@ -1089,6 +1090,9 @@ static int vorbis_floor0_decode(vorbis_context *vc, for (i = 0; i < order; i++) lsp[i] = 2.0f * cos(lsp[i]); + av_dlog(NULL, "floor0 synth: map_size = %"PRIu32"; m = %d; wstep = %f\n", + vf->map_size[blockflag], order, wstep); + i = 0; while (i < vf->map_size[blockflag]) { int j, iter_cond = vf->map[blockflag][i]; -- cgit v1.2.3 From b9478cfefb408ae1d476555b46893005e2d3bf4c Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Tue, 7 Jun 2011 10:52:30 +0200 Subject: shorten: Remove stray DEBUG #define and corresponding av_dlog statement. --- libavcodec/shorten.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c index 86e981f417..a6e00750e9 100644 --- a/libavcodec/shorten.c +++ b/libavcodec/shorten.c @@ -26,7 +26,6 @@ * */ -#define DEBUG #include #include "avcodec.h" #include "get_bits.h" @@ -304,7 +303,6 @@ static int shorten_decode_frame(AVCodecContext *avctx, s->bitstream_size= buf_size; if(buf_size < s->max_framesize){ - //av_dlog(avctx, "wanna more data ... %d\n", buf_size); *data_size = 0; return input_buf_size; } -- cgit v1.2.3 From bda9b20fa49975c6b9c39308818e7773eb78b411 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 5 Jun 2011 21:15:44 -0400 Subject: swscale: un-special-case yuv2yuvX16_c(). Make yuv2yuvX16_c a function pointer for yuv2yuvX(), so that the function pointer becomes bitdepth-independent. --- libswscale/ppc/swscale_altivec.c | 6 +++- libswscale/swscale.c | 63 ++++++++++++++++++++++----------------- libswscale/x86/swscale_template.c | 5 +++- 3 files changed, 44 insertions(+), 30 deletions(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index 7f4dfcd6f1..423297a8f0 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -403,11 +403,15 @@ static void hScale_altivec_real(int16_t *dst, int dstW, void ff_sws_init_swScale_altivec(SwsContext *c) { + enum PixelFormat dstFormat = c->dstFormat; + if (!(av_get_cpu_flags() & AV_CPU_FLAG_ALTIVEC)) return; c->hScale = hScale_altivec_real; - c->yuv2yuvX = yuv2yuvX_altivec_real; + if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat)) { + c->yuv2yuvX = yuv2yuvX_altivec_real; + } /* The following list of supported dstFormat values should * match what's found in the body of ff_yuv2packedX_altivec() */ diff --git a/libswscale/swscale.c b/libswscale/swscale.c index fd64b81019..35b0233f15 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -258,17 +258,20 @@ yuv2yuvX16_c_template(const int16_t *lumFilter, const int16_t **lumSrc, output_pixel(&aDest[i], val); } } +#undef output_pixel } #define yuv2NBPS(bits, BE_LE, is_be) \ -static void yuv2yuvX ## bits ## BE_LE ## _c(const int16_t *lumFilter, \ +static void yuv2yuvX ## bits ## BE_LE ## _c(SwsContext *c, const int16_t *lumFilter, \ const int16_t **lumSrc, int lumFilterSize, \ const int16_t *chrFilter, const int16_t **chrUSrc, \ const int16_t **chrVSrc, \ int chrFilterSize, const int16_t **alpSrc, \ - uint16_t *dest, uint16_t *uDest, uint16_t *vDest, \ - uint16_t *aDest, int dstW, int chrDstW) \ + uint8_t *_dest, uint8_t *_uDest, uint8_t *_vDest, \ + uint8_t *_aDest, int dstW, int chrDstW) \ { \ + uint16_t *dest = (uint16_t *) _dest, *uDest = (uint16_t *) _uDest, \ + *vDest = (uint16_t *) _vDest, *aDest = (uint16_t *) _aDest; \ yuv2yuvX16_c_template(lumFilter, lumSrc, lumFilterSize, \ chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ alpSrc, \ @@ -282,24 +285,24 @@ yuv2NBPS(10, LE, 0); yuv2NBPS(16, BE, 1); yuv2NBPS(16, LE, 0); -static inline void yuv2yuvX16_c(const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, +static inline void yuv2yuvX16_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint16_t *dest, uint16_t *uDest, uint16_t *vDest, uint16_t *aDest, int dstW, int chrDstW, + const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, int dstW, int chrDstW, enum PixelFormat dstFormat) { #define conv16(bits) \ if (isBE(dstFormat)) { \ - yuv2yuvX ## bits ## BE_c(lumFilter, lumSrc, lumFilterSize, \ - chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ - alpSrc, \ - dest, uDest, vDest, aDest, \ - dstW, chrDstW); \ + yuv2yuvX ## bits ## BE_c(c, lumFilter, lumSrc, lumFilterSize, \ + chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ + alpSrc, \ + dest, uDest, vDest, aDest, \ + dstW, chrDstW); \ } else { \ - yuv2yuvX ## bits ## LE_c(lumFilter, lumSrc, lumFilterSize, \ - chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ - alpSrc, \ - dest, uDest, vDest, aDest, \ - dstW, chrDstW); \ + yuv2yuvX ## bits ## LE_c(c, lumFilter, lumSrc, lumFilterSize, \ + chrFilter, chrUSrc, chrVSrc, chrFilterSize, \ + alpSrc, \ + dest, uDest, vDest, aDest, \ + dstW, chrDstW); \ } if (is16BPS(dstFormat)) { conv16(16); @@ -1783,14 +1786,7 @@ static int swScale(SwsContext *c, const uint8_t* src[], } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like const int chrSkipMask= (1<chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi - if (is16BPS(dstFormat) || is9_OR_10BPS(dstFormat)) { - yuv2yuvX16_c(vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, - vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, - chrVSrcPtr, vChrFilterSize, - alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, - (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW, - dstFormat); - } else if (vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12 + if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12 const int16_t *lumBuf = lumSrcPtr[0]; const int16_t *chrUBuf= chrUSrcPtr[0]; const int16_t *chrVBuf= chrVSrcPtr[0]; @@ -1870,9 +1866,9 @@ static int swScale(SwsContext *c, const uint8_t* src[], const int chrSkipMask= (1<chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi if (is16BPS(dstFormat) || is9_OR_10BPS(dstFormat)) { - yuv2yuvX16_c(vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, + yuv2yuvX16_c(c, vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - alpSrcPtr, (uint16_t *) dest, (uint16_t *) uDest, (uint16_t *) vDest, (uint16_t *) aDest, dstW, chrDstW, + alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW, dstFormat); } else { yuv2yuvX_c(c, vLumFilter+dstY*vLumFilterSize, @@ -1921,11 +1917,22 @@ static int swScale(SwsContext *c, const uint8_t* src[], static void sws_init_swScale_c(SwsContext *c) { - enum PixelFormat srcFormat = c->srcFormat; + enum PixelFormat srcFormat = c->srcFormat, + dstFormat = c->dstFormat; c->yuv2nv12X = yuv2nv12X_c; - c->yuv2yuv1 = yuv2yuv1_c; - c->yuv2yuvX = yuv2yuvX_c; + if (is16BPS(dstFormat)) { + c->yuv2yuvX = isBE(dstFormat) ? yuv2yuvX16BE_c : yuv2yuvX16LE_c; + } else if (is9_OR_10BPS(dstFormat)) { + if (dstFormat == PIX_FMT_YUV420P9BE || dstFormat == PIX_FMT_YUV420P9LE) { + c->yuv2yuvX = isBE(dstFormat) ? yuv2yuvX9BE_c : yuv2yuvX9LE_c; + } else { + c->yuv2yuvX = isBE(dstFormat) ? yuv2yuvX10BE_c : yuv2yuvX10LE_c; + } + } else { + c->yuv2yuv1 = yuv2yuv1_c; + c->yuv2yuvX = yuv2yuvX_c; + } c->yuv2packed1 = yuv2packed1_c; c->yuv2packed2 = yuv2packed2_c; c->yuv2packedX = yuv2packedX_c; diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index efaadaa09e..174c3fbfd6 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -2185,8 +2185,10 @@ static inline void RENAME(hcscale_fast)(SwsContext *c, int16_t *dst1, int16_t *d static void RENAME(sws_init_swScale)(SwsContext *c) { - enum PixelFormat srcFormat = c->srcFormat; + enum PixelFormat srcFormat = c->srcFormat, + dstFormat = c->dstFormat; + if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat)) { if (!(c->flags & SWS_BITEXACT)) { if (c->flags & SWS_ACCURATE_RND) { c->yuv2yuv1 = RENAME(yuv2yuv1_ar ); @@ -2236,6 +2238,7 @@ static void RENAME(sws_init_swScale)(SwsContext *c) break; } } + } #if !COMPILE_TEMPLATE_MMX2 c->hScale = RENAME(hScale ); -- cgit v1.2.3 From ea281753120f55fc3a3102ac54ba291d0ffcd43d Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 5 Jun 2011 21:37:59 -0400 Subject: swscale: remove alp/chr/lumSrcOffset. They are hacks added to reuse the same scaling function for different formats and they may cause problems when SIMD implementation of the same functions are used along with pure C functions. --- libswscale/swscale.c | 201 ++++++++++++++++-------------------------- libswscale/swscale_internal.h | 4 - 2 files changed, 76 insertions(+), 129 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 35b0233f15..d97c4e1259 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -979,93 +979,58 @@ static void fillPlane(uint8_t* plane, int stride, int width, int height, int y, } } -static void rgb48ToY_c(uint8_t *dst, const uint8_t *src, int width, - uint32_t *unused) -{ - int i; - for (i = 0; i < width; i++) { - int r = src[i*6+0]; - int g = src[i*6+2]; - int b = src[i*6+4]; - - dst[i] = (RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; - } -} - -static void rgb48ToUV_c(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused) -{ - int i; - assert(src1==src2); - for (i = 0; i < width; i++) { - int r = src1[6*i + 0]; - int g = src1[6*i + 2]; - int b = src1[6*i + 4]; - - dstU[i] = (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; - dstV[i] = (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; - } -} - -static void rgb48ToUV_half_c(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused) -{ - int i; - assert(src1==src2); - for (i = 0; i < width; i++) { - int r= src1[12*i + 0] + src1[12*i + 6]; - int g= src1[12*i + 2] + src1[12*i + 8]; - int b= src1[12*i + 4] + src1[12*i + 10]; - - dstU[i]= (RU*r + GU*g + BU*b + (257<> (RGB2YUV_SHIFT+1); - dstV[i]= (RV*r + GV*g + BV*b + (257<> (RGB2YUV_SHIFT+1); - } -} - -static void bgr48ToY_c(uint8_t *dst, const uint8_t *src, int width, - uint32_t *unused) -{ - int i; - for (i = 0; i < width; i++) { - int b = src[i*6+0]; - int g = src[i*6+2]; - int r = src[i*6+4]; - - dst[i] = (RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; - } -} - -static void bgr48ToUV_c(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused) -{ - int i; - for (i = 0; i < width; i++) { - int b = src1[6*i + 0]; - int g = src1[6*i + 2]; - int r = src1[6*i + 4]; - - dstU[i] = (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; - dstV[i] = (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; - } -} - -static void bgr48ToUV_half_c(uint8_t *dstU, uint8_t *dstV, - const uint8_t *src1, const uint8_t *src2, - int width, uint32_t *unused) -{ - int i; - for (i = 0; i < width; i++) { - int b= src1[12*i + 0] + src1[12*i + 6]; - int g= src1[12*i + 2] + src1[12*i + 8]; - int r= src1[12*i + 4] + src1[12*i + 10]; - - dstU[i]= (RU*r + GU*g + BU*b + (257<> (RGB2YUV_SHIFT+1); - dstV[i]= (RV*r + GV*g + BV*b + (257<> (RGB2YUV_SHIFT+1); - } +#define rgb48funcs(LE_BE, rfunc, compA, compB, compC) \ +static void compA ## compB ## compC ## 48 ## LE_BE ## ToY_c( \ + uint8_t *dst, const uint8_t *src, int width, \ + uint32_t *unused) \ +{ \ + int i; \ + for (i = 0; i < width; i++) { \ + int compA = rfunc(&src[i*6+0]) >> 8; \ + int compB = rfunc(&src[i*6+2]) >> 8; \ + int compC = rfunc(&src[i*6+4]) >> 8; \ + \ + dst[i] = (RY*r + GY*g + BY*b + (33<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; \ + } \ +} \ + \ +static void compA ## compB ## compC ## 48 ## LE_BE ## ToUV_c( \ + uint8_t *dstU, uint8_t *dstV, \ + const uint8_t *src1, const uint8_t *src2, \ + int width, uint32_t *unused) \ +{ \ + int i; \ + assert(src1==src2); \ + for (i = 0; i < width; i++) { \ + int compA = rfunc(&src1[6*i + 0]) >> 8; \ + int compB = rfunc(&src1[6*i + 2]) >> 8; \ + int compC = rfunc(&src1[6*i + 4]) >> 8; \ + \ + dstU[i] = (RU*r + GU*g + BU*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; \ + dstV[i] = (RV*r + GV*g + BV*b + (257<<(RGB2YUV_SHIFT-1))) >> RGB2YUV_SHIFT; \ + } \ +} \ + \ +static void compA ## compB ## compC ## 48 ## LE_BE ## ToUV_half_c( \ + uint8_t *dstU, uint8_t *dstV, \ + const uint8_t *src1, const uint8_t *src2, \ + int width, uint32_t *unused) \ +{ \ + int i; \ + assert(src1==src2); \ + for (i = 0; i < width; i++) { \ + int compA = (rfunc(&src1[12*i + 0]) >> 8) + (rfunc(&src1[12*i + 6]) >> 8); \ + int compB = (rfunc(&src1[12*i + 2]) >> 8) + (rfunc(&src1[12*i + 8]) >> 8); \ + int compC = (rfunc(&src1[12*i + 4]) >> 8) + (rfunc(&src1[12*i + 10]) >> 8); \ + \ + dstU[i]= (RU*r + GU*g + BU*b + (257<> (RGB2YUV_SHIFT+1); \ + dstV[i]= (RV*r + GV*g + BV*b + (257<> (RGB2YUV_SHIFT+1); \ + } \ } +rgb48funcs(LE, AV_RL16, r, g, b); +rgb48funcs(BE, AV_RB16, r, g, b); +rgb48funcs(LE, AV_RL16, b, g, r); +rgb48funcs(BE, AV_RB16, b, g, r); #define BGR2Y(type, name, shr, shg, shb, maskr, maskg, maskb, RY, GY, BY, S)\ static void name ## _c(uint8_t *dst, const uint8_t *src, \ @@ -1098,6 +1063,14 @@ static void abgrToA_c(uint8_t *dst, const uint8_t *src, int width, uint32_t *unu } } +static void rgbaToA_c(uint8_t *dst, const uint8_t *src, int width, uint32_t *unused) +{ + int i; + for (i=0; ialpToYV12 : c->lumToYV12; void (*convertRange)(uint16_t *, int) = isAlpha ? NULL : c->lumConvertRange; - src += isAlpha ? c->alpSrcOffset : c->lumSrcOffset; - if (toYV12) { toYV12(formatConvBuffer, src, srcW, pal); src= formatConvBuffer; @@ -1570,10 +1541,6 @@ static inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *dst2, int ds const int16_t *hChrFilterPos, int hChrFilterSize, uint8_t *formatConvBuffer, uint32_t *pal) { - - src1 += c->chrSrcOffset; - src2 += c->chrSrcOffset; - if (c->chrToYV12) { uint8_t *buf2 = formatConvBuffer + FFALIGN(srcW, 16); c->chrToYV12(formatConvBuffer, buf2, src1, src2, srcW, pal); @@ -1969,10 +1936,10 @@ static void sws_init_swScale_c(SwsContext *c) } if (c->chrSrcHSubSample) { switch(srcFormat) { - case PIX_FMT_RGB48BE: - case PIX_FMT_RGB48LE: c->chrToYV12 = rgb48ToUV_half_c; break; - case PIX_FMT_BGR48BE: - case PIX_FMT_BGR48LE: c->chrToYV12 = bgr48ToUV_half_c; break; + case PIX_FMT_RGB48BE: c->chrToYV12 = rgb48BEToUV_half_c; break; + case PIX_FMT_RGB48LE: c->chrToYV12 = rgb48LEToUV_half_c; break; + case PIX_FMT_BGR48BE: c->chrToYV12 = bgr48BEToUV_half_c; break; + case PIX_FMT_BGR48LE: c->chrToYV12 = bgr48LEToUV_half_c; break; case PIX_FMT_RGB32 : c->chrToYV12 = bgr32ToUV_half_c; break; case PIX_FMT_RGB32_1: c->chrToYV12 = bgr321ToUV_half_c; break; case PIX_FMT_BGR24 : c->chrToYV12 = bgr24ToUV_half_c; break; @@ -1986,10 +1953,10 @@ static void sws_init_swScale_c(SwsContext *c) } } else { switch(srcFormat) { - case PIX_FMT_RGB48BE: - case PIX_FMT_RGB48LE: c->chrToYV12 = rgb48ToUV_c; break; - case PIX_FMT_BGR48BE: - case PIX_FMT_BGR48LE: c->chrToYV12 = bgr48ToUV_c; break; + case PIX_FMT_RGB48BE: c->chrToYV12 = rgb48BEToUV_c; break; + case PIX_FMT_RGB48LE: c->chrToYV12 = rgb48LEToUV_c; break; + case PIX_FMT_BGR48BE: c->chrToYV12 = bgr48BEToUV_c; break; + case PIX_FMT_BGR48LE: c->chrToYV12 = bgr48LEToUV_c; break; case PIX_FMT_RGB32 : c->chrToYV12 = bgr32ToUV_c; break; case PIX_FMT_RGB32_1: c->chrToYV12 = bgr321ToUV_c; break; case PIX_FMT_BGR24 : c->chrToYV12 = bgr24ToUV_c; break; @@ -2038,37 +2005,21 @@ static void sws_init_swScale_c(SwsContext *c) case PIX_FMT_RGB32_1: c->lumToYV12 = bgr321ToY_c; break; case PIX_FMT_BGR32 : c->lumToYV12 = rgb32ToY_c; break; case PIX_FMT_BGR32_1: c->lumToYV12 = rgb321ToY_c; break; - case PIX_FMT_RGB48BE: - case PIX_FMT_RGB48LE: c->lumToYV12 = rgb48ToY_c; break; - case PIX_FMT_BGR48BE: - case PIX_FMT_BGR48LE: c->lumToYV12 = bgr48ToY_c; break; + case PIX_FMT_RGB48BE: c->lumToYV12 = rgb48BEToY_c; break; + case PIX_FMT_RGB48LE: c->lumToYV12 = rgb48LEToY_c; break; + case PIX_FMT_BGR48BE: c->lumToYV12 = bgr48BEToY_c; break; + case PIX_FMT_BGR48LE: c->lumToYV12 = bgr48LEToY_c; break; } if (c->alpPixBuf) { switch (srcFormat) { - case PIX_FMT_RGB32 : - case PIX_FMT_RGB32_1: - case PIX_FMT_BGR32 : - case PIX_FMT_BGR32_1: c->alpToYV12 = abgrToA_c; break; - case PIX_FMT_Y400A : c->alpToYV12 = yuy2ToY_c; break; + case PIX_FMT_BGRA: + case PIX_FMT_RGBA: c->alpToYV12 = rgbaToA_c; break; + case PIX_FMT_ABGR: + case PIX_FMT_ARGB: c->alpToYV12 = abgrToA_c; break; + case PIX_FMT_Y400A: c->alpToYV12 = uyvyToY_c; break; } } - switch (srcFormat) { - case PIX_FMT_Y400A : - c->alpSrcOffset = 1; - break; - case PIX_FMT_RGB32 : - case PIX_FMT_BGR32 : - c->alpSrcOffset = 3; - break; - case PIX_FMT_RGB48LE: - case PIX_FMT_BGR48LE: - c->lumSrcOffset = 1; - c->chrSrcOffset = 1; - c->alpSrcOffset = 1; - break; - } - if (c->srcRange != c->dstRange && !isAnyRGB(c->dstFormat)) { if (c->srcRange) { c->lumConvertRange = lumRangeFromJpeg_c; diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index 6aaa843015..a9adb3f07a 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -313,10 +313,6 @@ typedef struct SwsContext { void (*lumConvertRange)(uint16_t *dst, int width); ///< Color range conversion function for luma plane if needed. void (*chrConvertRange)(uint16_t *dst1, uint16_t *dst2, int width); ///< Color range conversion function for chroma planes if needed. - int lumSrcOffset; ///< Offset given to luma src pointers passed to horizontal input functions. - int chrSrcOffset; ///< Offset given to chroma src pointers passed to horizontal input functions. - int alpSrcOffset; ///< Offset given to alpha src pointers passed to horizontal input functions. - int needs_hcscale; ///< Set if there are chroma planes to be converted. } SwsContext; -- cgit v1.2.3 From b3b28b080f588a63d9bcf2714daa7119ece2da61 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 5 Jun 2011 21:40:04 -0400 Subject: swscale: cosmetics. --- libswscale/swscale.c | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index d97c4e1259..f6ed45382e 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1906,8 +1906,7 @@ static void sws_init_swScale_c(SwsContext *c) c->hScale = hScale_c; - if (c->flags & SWS_FAST_BILINEAR) - { + if (c->flags & SWS_FAST_BILINEAR) { c->hyscale_fast = hyscale_fast_c; c->hcscale_fast = hcscale_fast_c; } -- cgit v1.2.3 From ca364a5b43044bc98a7aef001fb1543b7b13411d Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 5 Jun 2011 21:46:16 -0400 Subject: swscale: extract SWS_FULL_CHR_H_INT conditional into init code. --- libswscale/ppc/swscale_altivec.c | 2 +- libswscale/swscale.c | 60 ++++++++++++++------------------------- libswscale/x86/swscale_template.c | 6 ++++ 3 files changed, 28 insertions(+), 40 deletions(-) diff --git a/libswscale/ppc/swscale_altivec.c b/libswscale/ppc/swscale_altivec.c index 423297a8f0..42e965de95 100644 --- a/libswscale/ppc/swscale_altivec.c +++ b/libswscale/ppc/swscale_altivec.c @@ -415,7 +415,7 @@ void ff_sws_init_swScale_altivec(SwsContext *c) /* The following list of supported dstFormat values should * match what's found in the body of ff_yuv2packedX_altivec() */ - if (!(c->flags & SWS_BITEXACT) && !c->alpPixBuf && + if (!(c->flags & (SWS_BITEXACT | SWS_FULL_CHR_H_INT)) && !c->alpPixBuf && (c->dstFormat==PIX_FMT_ABGR || c->dstFormat==PIX_FMT_BGRA || c->dstFormat==PIX_FMT_BGR24 || c->dstFormat==PIX_FMT_RGB24 || c->dstFormat==PIX_FMT_RGBA || c->dstFormat==PIX_FMT_ARGB)) { diff --git a/libswscale/swscale.c b/libswscale/swscale.c index f6ed45382e..9705b14d00 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1770,50 +1770,28 @@ static int swScale(SwsContext *c, const uint8_t* src[], } else { assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2); - if (vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB + if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB int chrAlpha= vChrFilter[2*dstY+1]; - if(flags & SWS_FULL_CHR_H_INT) { - yuv2rgbX_c_full(c, //FIXME write a packed1_full function - vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, - vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, - chrVSrcPtr, vChrFilterSize, - alpSrcPtr, dest, dstW, dstY); - } else { - c->yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1), - *chrVSrcPtr, *(chrVSrcPtr+1), - alpPixBuf ? *alpSrcPtr : NULL, - dest, dstW, chrAlpha, dstFormat, flags, dstY); - } - } else if (vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB + c->yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1), + *chrVSrcPtr, *(chrVSrcPtr+1), + alpPixBuf ? *alpSrcPtr : NULL, + dest, dstW, chrAlpha, dstFormat, flags, dstY); + } else if (c->yuv2packed2 && vLumFilterSize == 2 && vChrFilterSize == 2) { //bilinear upscale RGB int lumAlpha= vLumFilter[2*dstY+1]; int chrAlpha= vChrFilter[2*dstY+1]; lumMmxFilter[2]= lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001; chrMmxFilter[2]= chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001; - if(flags & SWS_FULL_CHR_H_INT) { - yuv2rgbX_c_full(c, //FIXME write a packed2_full function - vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, - vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - alpSrcPtr, dest, dstW, dstY); - } else { - c->yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1), - *chrVSrcPtr, *(chrVSrcPtr+1), - alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL, - dest, dstW, lumAlpha, chrAlpha, dstY); - } + c->yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1), + *chrVSrcPtr, *(chrVSrcPtr+1), + alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL, + dest, dstW, lumAlpha, chrAlpha, dstY); } else { //general RGB - if(flags & SWS_FULL_CHR_H_INT) { - yuv2rgbX_c_full(c, - vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, - vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - alpSrcPtr, dest, dstW, dstY); - } else { - c->yuv2packedX(c, - vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, - vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - alpSrcPtr, dest, dstW, dstY); - } + c->yuv2packedX(c, + vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, + vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, + alpSrcPtr, dest, dstW, dstY); } } } else { // hmm looks like we can't use MMX here without overwriting this array's tail @@ -1900,9 +1878,13 @@ static void sws_init_swScale_c(SwsContext *c) c->yuv2yuv1 = yuv2yuv1_c; c->yuv2yuvX = yuv2yuvX_c; } - c->yuv2packed1 = yuv2packed1_c; - c->yuv2packed2 = yuv2packed2_c; - c->yuv2packedX = yuv2packedX_c; + if(c->flags & SWS_FULL_CHR_H_INT) { + c->yuv2packedX = yuv2rgbX_c_full; + } else { + c->yuv2packed1 = yuv2packed1_c; + c->yuv2packed2 = yuv2packed2_c; + c->yuv2packedX = yuv2packedX_c; + } c->hScale = hScale_c; diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index 174c3fbfd6..bd72b75326 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -2193,6 +2193,7 @@ static void RENAME(sws_init_swScale)(SwsContext *c) if (c->flags & SWS_ACCURATE_RND) { c->yuv2yuv1 = RENAME(yuv2yuv1_ar ); c->yuv2yuvX = RENAME(yuv2yuvX_ar ); + if (!(c->flags & SWS_FULL_CHR_H_INT)) { switch (c->dstFormat) { case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break; case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X_ar); break; @@ -2201,9 +2202,11 @@ static void RENAME(sws_init_swScale)(SwsContext *c) case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break; default: break; } + } } else { c->yuv2yuv1 = RENAME(yuv2yuv1 ); c->yuv2yuvX = RENAME(yuv2yuvX ); + if (!(c->flags & SWS_FULL_CHR_H_INT)) { switch (c->dstFormat) { case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break; case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X); break; @@ -2212,7 +2215,10 @@ static void RENAME(sws_init_swScale)(SwsContext *c) case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X); break; default: break; } + } + } } + if (!(c->flags & SWS_FULL_CHR_H_INT)) { switch (c->dstFormat) { case PIX_FMT_RGB32: c->yuv2packed1 = RENAME(yuv2rgb32_1); -- cgit v1.2.3 From 0fb5193156053b820579df9ab4596b950eb05d4d Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 5 Jun 2011 21:48:51 -0400 Subject: swscale: reindent x86 init code. --- libswscale/x86/swscale_template.c | 70 +++++++++++++++++++-------------------- 1 file changed, 35 insertions(+), 35 deletions(-) diff --git a/libswscale/x86/swscale_template.c b/libswscale/x86/swscale_template.c index bd72b75326..3646ccceff 100644 --- a/libswscale/x86/swscale_template.c +++ b/libswscale/x86/swscale_template.c @@ -2189,62 +2189,62 @@ static void RENAME(sws_init_swScale)(SwsContext *c) dstFormat = c->dstFormat; if (!is16BPS(dstFormat) && !is9_OR_10BPS(dstFormat)) { - if (!(c->flags & SWS_BITEXACT)) { - if (c->flags & SWS_ACCURATE_RND) { - c->yuv2yuv1 = RENAME(yuv2yuv1_ar ); - c->yuv2yuvX = RENAME(yuv2yuvX_ar ); - if (!(c->flags & SWS_FULL_CHR_H_INT)) { - switch (c->dstFormat) { - case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break; - case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X_ar); break; - case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X_ar); break; - case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X_ar); break; - case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break; - default: break; - } - } - } else { - c->yuv2yuv1 = RENAME(yuv2yuv1 ); - c->yuv2yuvX = RENAME(yuv2yuvX ); - if (!(c->flags & SWS_FULL_CHR_H_INT)) { - switch (c->dstFormat) { - case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break; - case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X); break; - case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X); break; - case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X); break; - case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X); break; - default: break; + if (!(c->flags & SWS_BITEXACT)) { + if (c->flags & SWS_ACCURATE_RND) { + c->yuv2yuv1 = RENAME(yuv2yuv1_ar ); + c->yuv2yuvX = RENAME(yuv2yuvX_ar ); + if (!(c->flags & SWS_FULL_CHR_H_INT)) { + switch (c->dstFormat) { + case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X_ar); break; + case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X_ar); break; + case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X_ar); break; + case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X_ar); break; + case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X_ar); break; + default: break; + } + } + } else { + c->yuv2yuv1 = RENAME(yuv2yuv1 ); + c->yuv2yuvX = RENAME(yuv2yuvX ); + if (!(c->flags & SWS_FULL_CHR_H_INT)) { + switch (c->dstFormat) { + case PIX_FMT_RGB32: c->yuv2packedX = RENAME(yuv2rgb32_X); break; + case PIX_FMT_BGR24: c->yuv2packedX = RENAME(yuv2bgr24_X); break; + case PIX_FMT_RGB555: c->yuv2packedX = RENAME(yuv2rgb555_X); break; + case PIX_FMT_RGB565: c->yuv2packedX = RENAME(yuv2rgb565_X); break; + case PIX_FMT_YUYV422: c->yuv2packedX = RENAME(yuv2yuyv422_X); break; + default: break; + } + } } - } - } } if (!(c->flags & SWS_FULL_CHR_H_INT)) { - switch (c->dstFormat) { - case PIX_FMT_RGB32: + switch (c->dstFormat) { + case PIX_FMT_RGB32: c->yuv2packed1 = RENAME(yuv2rgb32_1); c->yuv2packed2 = RENAME(yuv2rgb32_2); break; - case PIX_FMT_BGR24: + case PIX_FMT_BGR24: c->yuv2packed1 = RENAME(yuv2bgr24_1); c->yuv2packed2 = RENAME(yuv2bgr24_2); break; - case PIX_FMT_RGB555: + case PIX_FMT_RGB555: c->yuv2packed1 = RENAME(yuv2rgb555_1); c->yuv2packed2 = RENAME(yuv2rgb555_2); break; - case PIX_FMT_RGB565: + case PIX_FMT_RGB565: c->yuv2packed1 = RENAME(yuv2rgb565_1); c->yuv2packed2 = RENAME(yuv2rgb565_2); break; - case PIX_FMT_YUYV422: + case PIX_FMT_YUYV422: c->yuv2packed1 = RENAME(yuv2yuyv422_1); c->yuv2packed2 = RENAME(yuv2yuyv422_2); break; - default: + default: break; + } } } - } #if !COMPILE_TEMPLATE_MMX2 c->hScale = RENAME(hScale ); -- cgit v1.2.3 From df91d091747395384a7c585cee568f9949e6c9f2 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 5 Jun 2011 22:27:45 -0400 Subject: swscale: integrate yuv2nv12X_C into yuv2yuvX() function pointers. --- libswscale/swscale.c | 27 ++++++++++++--------------- libswscale/swscale_internal.h | 6 ------ 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 9705b14d00..845af3d190 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -362,10 +362,13 @@ static inline void yuv2yuvX_c(SwsContext *c, const int16_t *lumFilter, static inline void yuv2nv12X_c(SwsContext *c, const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, - int chrFilterSize, uint8_t *dest, uint8_t *uDest, - int dstW, int chrDstW, enum PixelFormat dstFormat) + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, uint8_t *uDest, + uint8_t *vDest, uint8_t *aDest, + int dstW, int chrDstW) { + enum PixelFormat dstFormat = c->dstFormat; + //FIXME Optimize (just quickly written not optimized..) int i; for (i=0; ichrDstVSubSample)-1; - if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi - c->yuv2nv12X(c, - vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, - vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - dest, uDest, dstW, chrDstW, dstFormat); - } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like + if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 like const int chrSkipMask= (1<chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi if (c->yuv2yuv1 && vLumFilterSize == 1 && vChrFilterSize == 1) { // unscaled YV12 @@ -1805,8 +1801,8 @@ static int swScale(SwsContext *c, const uint8_t* src[], yuv2nv12X_c(c, vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, - chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - dest, uDest, dstW, chrDstW, dstFormat); + chrUSrcPtr, chrVSrcPtr, vChrFilterSize, NULL, + dest, uDest, NULL, NULL, dstW, chrDstW); } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 const int chrSkipMask= (1<chrDstVSubSample)-1; if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi @@ -1865,8 +1861,9 @@ static void sws_init_swScale_c(SwsContext *c) enum PixelFormat srcFormat = c->srcFormat, dstFormat = c->dstFormat; - c->yuv2nv12X = yuv2nv12X_c; - if (is16BPS(dstFormat)) { + if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { + c->yuv2yuvX = yuv2nv12X_c; + } else if (is16BPS(dstFormat)) { c->yuv2yuvX = isBE(dstFormat) ? yuv2yuvX16BE_c : yuv2yuvX16LE_c; } else if (is9_OR_10BPS(dstFormat)) { if (dstFormat == PIX_FMT_YUV420P9BE || dstFormat == PIX_FMT_YUV420P9LE) { diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index a9adb3f07a..dcf8eb522a 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -250,12 +250,6 @@ typedef struct SwsContext { #endif /* function pointers for swScale() */ - void (*yuv2nv12X )(struct SwsContext *c, - const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - uint8_t *dest, uint8_t *uDest, - int dstW, int chrDstW, int dstFormat); void (*yuv2yuv1 )(struct SwsContext *c, const int16_t *lumSrc, const int16_t *chrUSrc, const int16_t *chrVSrc, const int16_t *alpSrc, -- cgit v1.2.3 From b73fe700253f1e93c3ca10f72fc8159d7e12aaa1 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 5 Jun 2011 22:31:11 -0400 Subject: swscale: add yuv2planar/packed function typedefs. --- libswscale/swscale_internal.h | 74 +++++++++++++++++++++++-------------------- 1 file changed, 40 insertions(+), 34 deletions(-) diff --git a/libswscale/swscale_internal.h b/libswscale/swscale_internal.h index dcf8eb522a..013eef9e31 100644 --- a/libswscale/swscale_internal.h +++ b/libswscale/swscale_internal.h @@ -57,6 +57,41 @@ typedef int (*SwsFunc)(struct SwsContext *context, const uint8_t* src[], int srcStride[], int srcSliceY, int srcSliceH, uint8_t* dst[], int dstStride[]); +typedef void (*yuv2planar1_fn) (struct SwsContext *c, + const int16_t *lumSrc, const int16_t *chrUSrc, + const int16_t *chrVSrc, const int16_t *alpSrc, + uint8_t *dest, + uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, + int dstW, int chrDstW); +typedef void (*yuv2planarX_fn) (struct SwsContext *c, + const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, + uint8_t *dest, + uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, + int dstW, int chrDstW); +typedef void (*yuv2packed1_fn) (struct SwsContext *c, + const uint16_t *buf0, + const uint16_t *ubuf0, const uint16_t *ubuf1, + const uint16_t *vbuf0, const uint16_t *vbuf1, + const uint16_t *abuf0, + uint8_t *dest, + int dstW, int uvalpha, int dstFormat, int flags, int y); +typedef void (*yuv2packed2_fn) (struct SwsContext *c, + const uint16_t *buf0, const uint16_t *buf1, + const uint16_t *ubuf0, const uint16_t *ubuf1, + const uint16_t *vbuf0, const uint16_t *vbuf1, + const uint16_t *abuf0, const uint16_t *abuf1, + uint8_t *dest, + int dstW, int yalpha, int uvalpha, int y); +typedef void (*yuv2packedX_fn) (struct SwsContext *c, + const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, + const int16_t *chrFilter, const int16_t **chrUSrc, + const int16_t **chrVSrc, int chrFilterSize, + const int16_t **alpSrc, uint8_t *dest, + int dstW, int dstY); + /* This struct should be aligned on at least a 32-byte boundary. */ typedef struct SwsContext { /** @@ -250,40 +285,11 @@ typedef struct SwsContext { #endif /* function pointers for swScale() */ - void (*yuv2yuv1 )(struct SwsContext *c, - const int16_t *lumSrc, const int16_t *chrUSrc, - const int16_t *chrVSrc, const int16_t *alpSrc, - uint8_t *dest, - uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, - int dstW, int chrDstW); - void (*yuv2yuvX )(struct SwsContext *c, - const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, - uint8_t *dest, - uint8_t *uDest, uint8_t *vDest, uint8_t *aDest, - int dstW, int chrDstW); - void (*yuv2packed1)(struct SwsContext *c, - const uint16_t *buf0, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, - uint8_t *dest, - int dstW, int uvalpha, int dstFormat, int flags, int y); - void (*yuv2packed2)(struct SwsContext *c, - const uint16_t *buf0, const uint16_t *buf1, - const uint16_t *ubuf0, const uint16_t *ubuf1, - const uint16_t *vbuf0, const uint16_t *vbuf1, - const uint16_t *abuf0, const uint16_t *abuf1, - uint8_t *dest, - int dstW, int yalpha, int uvalpha, int y); - void (*yuv2packedX)(struct SwsContext *c, - const int16_t *lumFilter, const int16_t **lumSrc, int lumFilterSize, - const int16_t *chrFilter, const int16_t **chrUSrc, - const int16_t **chrVSrc, int chrFilterSize, - const int16_t **alpSrc, uint8_t *dest, - int dstW, int dstY); + yuv2planar1_fn yuv2yuv1; + yuv2planarX_fn yuv2yuvX; + yuv2packed1_fn yuv2packed1; + yuv2packed2_fn yuv2packed2; + yuv2packedX_fn yuv2packedX; void (*lumToYV12)(uint8_t *dst, const uint8_t *src, int width, uint32_t *pal); ///< Unscaled conversion of luma plane to YV12 for horizontal scaler. -- cgit v1.2.3 From edeb56fa31071841125f723b741858a4187ee748 Mon Sep 17 00:00:00 2001 From: "Ronald S. Bultje" Date: Sun, 5 Jun 2011 22:54:30 -0400 Subject: swscale: remove duplicate conversion routine in swScale(). --- libswscale/swscale.c | 126 ++++++++++++++++++++++----------------------------- 1 file changed, 53 insertions(+), 73 deletions(-) diff --git a/libswscale/swscale.c b/libswscale/swscale.c index 845af3d190..8f41547be1 100644 --- a/libswscale/swscale.c +++ b/libswscale/swscale.c @@ -1562,6 +1562,37 @@ static inline void hcscale(SwsContext *c, uint16_t *dst1, uint16_t *dst2, int ds c->chrConvertRange(dst1, dst2, dstWidth); } +static av_always_inline void +find_c_packed_planar_out_funcs(SwsContext *c, + yuv2planar1_fn *yuv2yuv1, yuv2planarX_fn *yuv2yuvX, + yuv2packed1_fn *yuv2packed1, yuv2packed2_fn *yuv2packed2, + yuv2packedX_fn *yuv2packedX) +{ + enum PixelFormat dstFormat = c->dstFormat; + + if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { + *yuv2yuvX = yuv2nv12X_c; + } else if (is16BPS(dstFormat)) { + *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX16BE_c : yuv2yuvX16LE_c; + } else if (is9_OR_10BPS(dstFormat)) { + if (dstFormat == PIX_FMT_YUV420P9BE || dstFormat == PIX_FMT_YUV420P9LE) { + *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX9BE_c : yuv2yuvX9LE_c; + } else { + *yuv2yuvX = isBE(dstFormat) ? yuv2yuvX10BE_c : yuv2yuvX10LE_c; + } + } else { + *yuv2yuv1 = yuv2yuv1_c; + *yuv2yuvX = yuv2yuvX_c; + } + if(c->flags & SWS_FULL_CHR_H_INT) { + *yuv2packedX = yuv2rgbX_c_full; + } else { + *yuv2packed1 = yuv2packed1_c; + *yuv2packed2 = yuv2packed2_c; + *yuv2packedX = yuv2packedX_c; + } +} + #define DEBUG_SWSCALE_BUFFERS 0 #define DEBUG_BUFFERS(...) if (DEBUG_SWSCALE_BUFFERS) av_log(c, AV_LOG_DEBUG, __VA_ARGS__) @@ -1605,6 +1636,11 @@ static int swScale(SwsContext *c, const uint8_t* src[], const int chrSrcSliceH= -((-srcSliceH) >> c->chrSrcVSubSample); int lastDstY; uint32_t *pal=c->pal_yuv; + yuv2planar1_fn yuv2yuv1 = c->yuv2yuv1; + yuv2planarX_fn yuv2yuvX = c->yuv2yuvX; + yuv2packed1_fn yuv2packed1 = c->yuv2packed1; + yuv2packed2_fn yuv2packed2 = c->yuv2packed2; + yuv2packedX_fn yuv2packedX = c->yuv2packedX; /* vars which will change and which we need to store back in the context */ int dstY= c->dstY; @@ -1741,7 +1777,14 @@ static int swScale(SwsContext *c, const uint8_t* src[], #if HAVE_MMX updateMMXDitherTables(c, dstY, lumBufIndex, chrBufIndex, lastInLumBuf, lastInChrBuf); #endif - if (dstY < dstH-2) { + if (dstY >= dstH-2) { + // hmm looks like we can't use MMX here without overwriting this array's tail + find_c_packed_planar_out_funcs(c, &yuv2yuv1, &yuv2yuvX, + &yuv2packed1, &yuv2packed2, + &yuv2packedX); + } + + { const int16_t **lumSrcPtr= (const int16_t **) lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; const int16_t **chrUSrcPtr= (const int16_t **) chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; const int16_t **chrVSrcPtr= (const int16_t **) chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; @@ -1754,10 +1797,10 @@ static int swScale(SwsContext *c, const uint8_t* src[], const int16_t *chrUBuf= chrUSrcPtr[0]; const int16_t *chrVBuf= chrVSrcPtr[0]; const int16_t *alpBuf= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? alpSrcPtr[0] : NULL; - c->yuv2yuv1(c, lumBuf, chrUBuf, chrVBuf, alpBuf, dest, + yuv2yuv1(c, lumBuf, chrUBuf, chrVBuf, alpBuf, dest, uDest, vDest, aDest, dstW, chrDstW); } else { //General YV12 - c->yuv2yuvX(c, + yuv2yuvX(c, vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, @@ -1768,7 +1811,7 @@ static int swScale(SwsContext *c, const uint8_t* src[], assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2); if (c->yuv2packed1 && vLumFilterSize == 1 && vChrFilterSize == 2) { //unscaled RGB int chrAlpha= vChrFilter[2*dstY+1]; - c->yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1), + yuv2packed1(c, *lumSrcPtr, *chrUSrcPtr, *(chrUSrcPtr+1), *chrVSrcPtr, *(chrVSrcPtr+1), alpPixBuf ? *alpSrcPtr : NULL, dest, dstW, chrAlpha, dstFormat, flags, dstY); @@ -1779,61 +1822,17 @@ static int swScale(SwsContext *c, const uint8_t* src[], lumMmxFilter[3]= vLumFilter[2*dstY ]*0x10001; chrMmxFilter[2]= chrMmxFilter[3]= vChrFilter[2*chrDstY]*0x10001; - c->yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1), + yuv2packed2(c, *lumSrcPtr, *(lumSrcPtr+1), *chrUSrcPtr, *(chrUSrcPtr+1), *chrVSrcPtr, *(chrVSrcPtr+1), alpPixBuf ? *alpSrcPtr : NULL, alpPixBuf ? *(alpSrcPtr+1) : NULL, dest, dstW, lumAlpha, chrAlpha, dstY); } else { //general RGB - c->yuv2packedX(c, + yuv2packedX(c, vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, alpSrcPtr, dest, dstW, dstY); } } - } else { // hmm looks like we can't use MMX here without overwriting this array's tail - const int16_t **lumSrcPtr= (const int16_t **)lumPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize; - const int16_t **chrUSrcPtr= (const int16_t **)chrUPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; - const int16_t **chrVSrcPtr= (const int16_t **)chrVPixBuf + chrBufIndex + firstChrSrcY - lastInChrBuf + vChrBufSize; - const int16_t **alpSrcPtr= (CONFIG_SWSCALE_ALPHA && alpPixBuf) ? (const int16_t **)alpPixBuf + lumBufIndex + firstLumSrcY - lastInLumBuf + vLumBufSize : NULL; - if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { - const int chrSkipMask= (1<chrDstVSubSample)-1; - if (dstY&chrSkipMask) uDest= NULL; //FIXME split functions in lumi / chromi - yuv2nv12X_c(c, vLumFilter+dstY*vLumFilterSize, - lumSrcPtr, vLumFilterSize, - vChrFilter+chrDstY*vChrFilterSize, - chrUSrcPtr, chrVSrcPtr, vChrFilterSize, NULL, - dest, uDest, NULL, NULL, dstW, chrDstW); - } else if (isPlanarYUV(dstFormat) || dstFormat==PIX_FMT_GRAY8) { //YV12 - const int chrSkipMask= (1<chrDstVSubSample)-1; - if ((dstY&chrSkipMask) || isGray(dstFormat)) uDest=vDest= NULL; //FIXME split functions in lumi / chromi - if (is16BPS(dstFormat) || is9_OR_10BPS(dstFormat)) { - yuv2yuvX16_c(c, vLumFilter+dstY*vLumFilterSize , lumSrcPtr, vLumFilterSize, - vChrFilter+chrDstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - alpSrcPtr, dest, uDest, vDest, aDest, dstW, chrDstW, - dstFormat); - } else { - yuv2yuvX_c(c, vLumFilter+dstY*vLumFilterSize, - lumSrcPtr, vLumFilterSize, - vChrFilter+chrDstY*vChrFilterSize, - chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - alpSrcPtr, dest, uDest, vDest, aDest, - dstW, chrDstW); - } - } else { - assert(lumSrcPtr + vLumFilterSize - 1 < lumPixBuf + vLumBufSize*2); - assert(chrUSrcPtr + vChrFilterSize - 1 < chrUPixBuf + vChrBufSize*2); - if(flags & SWS_FULL_CHR_H_INT) { - yuv2rgbX_c_full(c, - vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, - vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - alpSrcPtr, dest, dstW, dstY); - } else { - yuv2packedX_c(c, - vLumFilter+dstY*vLumFilterSize, lumSrcPtr, vLumFilterSize, - vChrFilter+dstY*vChrFilterSize, chrUSrcPtr, chrVSrcPtr, vChrFilterSize, - alpSrcPtr, dest, dstW, dstY); - } - } } } @@ -1858,30 +1857,11 @@ static int swScale(SwsContext *c, const uint8_t* src[], static void sws_init_swScale_c(SwsContext *c) { - enum PixelFormat srcFormat = c->srcFormat, - dstFormat = c->dstFormat; + enum PixelFormat srcFormat = c->srcFormat; - if (dstFormat == PIX_FMT_NV12 || dstFormat == PIX_FMT_NV21) { - c->yuv2yuvX = yuv2nv12X_c; - } else if (is16BPS(dstFormat)) { - c->yuv2yuvX = isBE(dstFormat) ? yuv2yuvX16BE_c : yuv2yuvX16LE_c; - } else if (is9_OR_10BPS(dstFormat)) { - if (dstFormat == PIX_FMT_YUV420P9BE || dstFormat == PIX_FMT_YUV420P9LE) { - c->yuv2yuvX = isBE(dstFormat) ? yuv2yuvX9BE_c : yuv2yuvX9LE_c; - } else { - c->yuv2yuvX = isBE(dstFormat) ? yuv2yuvX10BE_c : yuv2yuvX10LE_c; - } - } else { - c->yuv2yuv1 = yuv2yuv1_c; - c->yuv2yuvX = yuv2yuvX_c; - } - if(c->flags & SWS_FULL_CHR_H_INT) { - c->yuv2packedX = yuv2rgbX_c_full; - } else { - c->yuv2packed1 = yuv2packed1_c; - c->yuv2packed2 = yuv2packed2_c; - c->yuv2packedX = yuv2packedX_c; - } + find_c_packed_planar_out_funcs(c, &c->yuv2yuv1, &c->yuv2yuvX, + &c->yuv2packed1, &c->yuv2packed2, + &c->yuv2packedX); c->hScale = hScale_c; -- cgit v1.2.3 From 2f37321abcbf9be5f58647b17155c0e257949c0d Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Mon, 6 Jun 2011 17:10:11 -0400 Subject: iirfilter: fix biquad filter coefficients. The current filter implementation should only have the cx coefficients divided by gain in order to give the correct output scale. --- libavcodec/iirfilter.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/libavcodec/iirfilter.c b/libavcodec/iirfilter.c index 98366e2c08..a942068aee 100644 --- a/libavcodec/iirfilter.c +++ b/libavcodec/iirfilter.c @@ -151,8 +151,6 @@ static int biquad_init_coeffs(void *avc, struct FFIIRFilterCoeffs *c, // during filtering, the delay state will include the gain multiplication c->cx[0] = lrintf(x0 / c->gain); c->cx[1] = lrintf(x1 / c->gain); - c->cy[0] /= c->gain; - c->cy[1] /= c->gain; return 0; } -- cgit v1.2.3 From a6703faa157294efb75619f55c06d7ed5a0aa2bf Mon Sep 17 00:00:00 2001 From: Stefano Sabatini Date: Mon, 6 Jun 2011 01:14:50 +0200 Subject: samplefmt: add av_get_bytes_per_sample() Deprecate av_get_bits_per_sample_fmt(), which was a misnamed function. For the moment we don't have sample formats with a non-integer number of bytes, in that case we may need to create a new av_get_bits_per_sample() function. In the meanwhile we prefer to adopt this variant, since avoids divisions by 8 all over the place. --- doc/APIchanges | 4 ++++ libavutil/avutil.h | 5 ++++- libavutil/samplefmt.c | 8 ++++++++ libavutil/samplefmt.h | 16 +++++++++++++--- 4 files changed, 29 insertions(+), 4 deletions(-) diff --git a/doc/APIchanges b/doc/APIchanges index 77eb6d2d27..1133397a43 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,6 +13,10 @@ libavutil: 2011-04-18 API changes, most recent first: +2011-06-07 - xxxxxxx - lavu 51.4.0 - av_get_bytes_per_sample() + Add av_get_bytes_per_sample() in libavutil/samplefmt.h. + Deprecate av_get_bits_per_sample_fmt(). + 2011-06-xx - xxxxxxx - lavu 51.3.0 - opt.h Add av_opt_free convenience function. diff --git a/libavutil/avutil.h b/libavutil/avutil.h index 5085a6dd0b..8536790109 100644 --- a/libavutil/avutil.h +++ b/libavutil/avutil.h @@ -40,7 +40,7 @@ #define AV_VERSION(a, b, c) AV_VERSION_DOT(a, b, c) #define LIBAVUTIL_VERSION_MAJOR 51 -#define LIBAVUTIL_VERSION_MINOR 3 +#define LIBAVUTIL_VERSION_MINOR 4 #define LIBAVUTIL_VERSION_MICRO 0 #define LIBAVUTIL_VERSION_INT AV_VERSION_INT(LIBAVUTIL_VERSION_MAJOR, \ @@ -57,6 +57,9 @@ * Those FF_API_* defines are not part of public API. * They may change, break or disappear at any time. */ +#ifndef FF_API_GET_BITS_PER_SAMPLE_FMT +#define FF_API_GET_BITS_PER_SAMPLE_FMT (LIBAVUTIL_VERSION_MAJOR < 52) +#endif /** * Return the LIBAVUTIL_VERSION_INT constant. diff --git a/libavutil/samplefmt.c b/libavutil/samplefmt.c index 06b50d9bd9..5b0bfa0257 100644 --- a/libavutil/samplefmt.c +++ b/libavutil/samplefmt.c @@ -66,8 +66,16 @@ char *av_get_sample_fmt_string (char *buf, int buf_size, enum AVSampleFormat sam return buf; } +int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt) +{ + return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? + 0 : sample_fmt_info[sample_fmt].bits >> 3; +} + +#if FF_API_GET_BITS_PER_SAMPLE_FMT int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt) { return sample_fmt < 0 || sample_fmt >= AV_SAMPLE_FMT_NB ? 0 : sample_fmt_info[sample_fmt].bits; } +#endif diff --git a/libavutil/samplefmt.h b/libavutil/samplefmt.h index 2326f4a11a..e38214927f 100644 --- a/libavutil/samplefmt.h +++ b/libavutil/samplefmt.h @@ -19,6 +19,8 @@ #ifndef AVUTIL_SAMPLEFMT_H #define AVUTIL_SAMPLEFMT_H +#include "avutil.h" + /** * all in native-endian format */ @@ -58,13 +60,21 @@ enum AVSampleFormat av_get_sample_fmt(const char *name); */ char *av_get_sample_fmt_string(char *buf, int buf_size, enum AVSampleFormat sample_fmt); +#if FF_API_GET_BITS_PER_SAMPLE_FMT +/** + * @deprecated Use av_get_bytes_per_sample() instead. + */ +attribute_deprecated +int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt); +#endif + /** - * Return sample format bits per sample. + * Return number of bytes per sample. * * @param sample_fmt the sample format - * @return number of bits per sample or zero if unknown for the given + * @return number of bytes per sample or zero if unknown for the given * sample format */ -int av_get_bits_per_sample_fmt(enum AVSampleFormat sample_fmt); +int av_get_bytes_per_sample(enum AVSampleFormat sample_fmt); #endif /* AVUTIL_SAMPLEFMT_H */ -- cgit v1.2.3 From 1397ac0aa0ac98333b9e88d258b625eec99c011f Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 7 Jun 2011 13:04:06 -0400 Subject: APIchanges: fill-in git commit hash for av_get_bytes_per_sample() addition --- doc/APIchanges | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/APIchanges b/doc/APIchanges index 1133397a43..0ce63fc382 100644 --- a/doc/APIchanges +++ b/doc/APIchanges @@ -13,7 +13,7 @@ libavutil: 2011-04-18 API changes, most recent first: -2011-06-07 - xxxxxxx - lavu 51.4.0 - av_get_bytes_per_sample() +2011-06-07 - a6703fa - lavu 51.4.0 - av_get_bytes_per_sample() Add av_get_bytes_per_sample() in libavutil/samplefmt.h. Deprecate av_get_bits_per_sample_fmt(). -- cgit v1.2.3 From 7b20d35a543c6635c348f3b312b5fa24137c0f95 Mon Sep 17 00:00:00 2001 From: John Stebbins Date: Tue, 7 Jun 2011 19:53:31 +0200 Subject: vc1: re-initialize tables after width/height change. read_sequence_header can change width/height; therefore, re-initialize all tables if width/height changed Signed-off-by: Anton Khirnov --- libavcodec/vc1dec.c | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/libavcodec/vc1dec.c b/libavcodec/vc1dec.c index 5c931b122a..186610ea95 100644 --- a/libavcodec/vc1dec.c +++ b/libavcodec/vc1dec.c @@ -3398,7 +3398,7 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) VC1Context *v = avctx->priv_data; MpegEncContext *s = &v->s; GetBitContext gb; - int i; + int i, cur_width, cur_height; if (!avctx->extradata_size || !avctx->extradata) return -1; if (!(avctx->flags & CODEC_FLAG_GRAY)) @@ -3419,8 +3419,8 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) if (vc1_init_common(v) < 0) return -1; ff_vc1dsp_init(&v->vc1dsp); - avctx->coded_width = avctx->width; - avctx->coded_height = avctx->height; + cur_width = avctx->coded_width = avctx->width; + cur_height = avctx->coded_height = avctx->height; if (avctx->codec_id == CODEC_ID_WMV3) { int count = 0; @@ -3491,6 +3491,19 @@ static av_cold int vc1_decode_init(AVCodecContext *avctx) } v->res_sprite = (avctx->codec_tag == MKTAG('W','V','P','2')); } + // Sequence header information may not have been parsed + // yet when ff_msmpeg4_decode_init was called the fist time + // above. If sequence information changes, we need to call + // it again. + if (cur_width != avctx->width || + cur_height != avctx->height) { + MPV_common_end(s); + if(ff_msmpeg4_decode_init(avctx) < 0) + return -1; + avctx->coded_width = avctx->width; + avctx->coded_height = avctx->height; + } + avctx->profile = v->profile; if (v->profile == PROFILE_ADVANCED) avctx->level = v->level; -- cgit v1.2.3 From a8bd53402a6d361b3da7c2c206c999b12ea1e5c6 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 7 Jun 2011 10:53:44 -0400 Subject: ac3enc: remove unused #define --- libavcodec/ac3enc.c | 3 --- 1 file changed, 3 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 53f6251a5e..4ee3c175d7 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -50,9 +50,6 @@ #endif -/** Maximum number of exponent groups. +1 for separate DC exponent. */ -#define AC3_MAX_EXP_GROUPS 85 - #if CONFIG_AC3ENC_FLOAT #define MAC_COEF(d,a,b) ((d)+=(a)*(b)) typedef float SampleType; -- cgit v1.2.3 From 787a13535a451b802a23abf211a34840c27bbc23 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 7 Jun 2011 11:50:38 -0400 Subject: ac3enc: remove convenience macro, #define DEBUG --- libavcodec/ac3enc.c | 1 - 1 file changed, 1 deletion(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 4ee3c175d7..1ab0c62b91 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -26,7 +26,6 @@ * The simplest AC-3 encoder. */ -//#define DEBUG //#define ASSERT_LEVEL 2 #include -- cgit v1.2.3 From c8e9ea43d004be04e4a9a07736104d099a5bf1f9 Mon Sep 17 00:00:00 2001 From: Justin Ruggles Date: Tue, 7 Jun 2011 12:47:09 -0400 Subject: Move E-AC-3 encoder functions to a separate eac3enc.c file. --- libavcodec/Makefile | 3 +- libavcodec/ac3enc.c | 284 +-------------------------------------------------- libavcodec/ac3enc.h | 214 ++++++++++++++++++++++++++++++++++++++ libavcodec/eac3enc.c | 131 ++++++++++++++++++++++++ libavcodec/eac3enc.h | 44 ++++++++ 5 files changed, 396 insertions(+), 280 deletions(-) create mode 100644 libavcodec/ac3enc.h create mode 100644 libavcodec/eac3enc.c create mode 100644 libavcodec/eac3enc.h diff --git a/libavcodec/Makefile b/libavcodec/Makefile index b772bf185e..7fd6b49d32 100644 --- a/libavcodec/Makefile +++ b/libavcodec/Makefile @@ -124,7 +124,8 @@ OBJS-$(CONFIG_DVVIDEO_DECODER) += dv.o dvdata.o OBJS-$(CONFIG_DVVIDEO_ENCODER) += dv.o dvdata.o OBJS-$(CONFIG_DXA_DECODER) += dxa.o OBJS-$(CONFIG_EAC3_DECODER) += eac3dec.o eac3dec_data.o -OBJS-$(CONFIG_EAC3_ENCODER) += ac3enc_float.o ac3tab.o ac3.o kbdwin.o +OBJS-$(CONFIG_EAC3_ENCODER) += eac3enc.o ac3enc_float.o ac3tab.o \ + ac3.o kbdwin.o OBJS-$(CONFIG_EACMV_DECODER) += eacmv.o OBJS-$(CONFIG_EAMAD_DECODER) += eamad.o eaidct.o mpeg12.o \ mpeg12data.o mpegvideo.o \ diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 1ab0c62b91..9e011af094 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -42,183 +42,8 @@ #include "ac3.h" #include "audioconvert.h" #include "fft.h" - - -#ifndef CONFIG_AC3ENC_FLOAT -#define CONFIG_AC3ENC_FLOAT 0 -#endif - - -#if CONFIG_AC3ENC_FLOAT -#define MAC_COEF(d,a,b) ((d)+=(a)*(b)) -typedef float SampleType; -typedef float CoefType; -typedef float CoefSumType; -#else -#define MAC_COEF(d,a,b) MAC64(d,a,b) -typedef int16_t SampleType; -typedef int32_t CoefType; -typedef int64_t CoefSumType; -#endif - -typedef struct AC3MDCTContext { - const SampleType *window; ///< MDCT window function - FFTContext fft; ///< FFT context for MDCT calculation -} AC3MDCTContext; - -/** - * Encoding Options used by AVOption. - */ -typedef struct AC3EncOptions { - /* AC-3 metadata options*/ - int dialogue_level; - int bitstream_mode; - float center_mix_level; - float surround_mix_level; - int dolby_surround_mode; - int audio_production_info; - int mixing_level; - int room_type; - int copyright; - int original; - int extended_bsi_1; - int preferred_stereo_downmix; - float ltrt_center_mix_level; - float ltrt_surround_mix_level; - float loro_center_mix_level; - float loro_surround_mix_level; - int extended_bsi_2; - int dolby_surround_ex_mode; - int dolby_headphone_mode; - int ad_converter_type; - - /* other encoding options */ - int allow_per_frame_metadata; - int stereo_rematrixing; - int channel_coupling; - int cpl_start; -} AC3EncOptions; - -/** - * Data for a single audio block. - */ -typedef struct AC3Block { - CoefType **mdct_coef; ///< MDCT coefficients - int32_t **fixed_coef; ///< fixed-point MDCT coefficients - uint8_t **exp; ///< original exponents - uint8_t **grouped_exp; ///< grouped exponents - int16_t **psd; ///< psd per frequency bin - int16_t **band_psd; ///< psd per critical band - int16_t **mask; ///< masking curve - uint16_t **qmant; ///< quantized mantissas - uint8_t **cpl_coord_exp; ///< coupling coord exponents (cplcoexp) - uint8_t **cpl_coord_mant; ///< coupling coord mantissas (cplcomant) - uint8_t coeff_shift[AC3_MAX_CHANNELS]; ///< fixed-point coefficient shift values - uint8_t new_rematrixing_strategy; ///< send new rematrixing flags in this block - int num_rematrixing_bands; ///< number of rematrixing bands - uint8_t rematrixing_flags[4]; ///< rematrixing flags - int new_cpl_strategy; ///< send new coupling strategy - int cpl_in_use; ///< coupling in use for this block (cplinu) - uint8_t channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling (chincpl) - int num_cpl_channels; ///< number of channels in coupling - uint8_t new_cpl_coords; ///< send new coupling coordinates (cplcoe) - uint8_t cpl_master_exp[AC3_MAX_CHANNELS]; ///< coupling coord master exponents (mstrcplco) - int new_snr_offsets; ///< send new SNR offsets - int new_cpl_leak; ///< send new coupling leak info - int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin (endmant) -} AC3Block; - -/** - * AC-3 encoder private context. - */ -typedef struct AC3EncodeContext { - AVClass *av_class; ///< AVClass used for AVOption - AC3EncOptions options; ///< encoding options - PutBitContext pb; ///< bitstream writer context - DSPContext dsp; - AC3DSPContext ac3dsp; ///< AC-3 optimized functions - AC3MDCTContext mdct; ///< MDCT context - - AC3Block blocks[AC3_MAX_BLOCKS]; ///< per-block info - - int eac3; ///< indicates if this is E-AC-3 vs. AC-3 - int bitstream_id; ///< bitstream id (bsid) - int bitstream_mode; ///< bitstream mode (bsmod) - - int bit_rate; ///< target bit rate, in bits-per-second - int sample_rate; ///< sampling frequency, in Hz - - int frame_size_min; ///< minimum frame size in case rounding is necessary - int frame_size; ///< current frame size in bytes - int frame_size_code; ///< frame size code (frmsizecod) - uint16_t crc_inv[2]; - int64_t bits_written; ///< bit count (used to avg. bitrate) - int64_t samples_written; ///< sample count (used to avg. bitrate) - - int fbw_channels; ///< number of full-bandwidth channels (nfchans) - int channels; ///< total number of channels (nchans) - int lfe_on; ///< indicates if there is an LFE channel (lfeon) - int lfe_channel; ///< channel index of the LFE channel - int has_center; ///< indicates if there is a center channel - int has_surround; ///< indicates if there are one or more surround channels - int channel_mode; ///< channel mode (acmod) - const uint8_t *channel_map; ///< channel map used to reorder channels - - int center_mix_level; ///< center mix level code - int surround_mix_level; ///< surround mix level code - int ltrt_center_mix_level; ///< Lt/Rt center mix level code - int ltrt_surround_mix_level; ///< Lt/Rt surround mix level code - int loro_center_mix_level; ///< Lo/Ro center mix level code - int loro_surround_mix_level; ///< Lo/Ro surround mix level code - - int cutoff; ///< user-specified cutoff frequency, in Hz - int bandwidth_code; ///< bandwidth code (0 to 60) (chbwcod) - int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin (strtmant) - int cpl_end_freq; ///< coupling channel end frequency bin - - int cpl_on; ///< coupling turned on for this frame - int cpl_enabled; ///< coupling enabled for all frames - int num_cpl_subbands; ///< number of coupling subbands (ncplsubnd) - int num_cpl_bands; ///< number of coupling bands (ncplbnd) - uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS]; ///< number of coeffs in each coupling band - - int rematrixing_enabled; ///< stereo rematrixing enabled - - /* bitrate allocation control */ - int slow_gain_code; ///< slow gain code (sgaincod) - int slow_decay_code; ///< slow decay code (sdcycod) - int fast_decay_code; ///< fast decay code (fdcycod) - int db_per_bit_code; ///< dB/bit code (dbpbcod) - int floor_code; ///< floor code (floorcod) - AC3BitAllocParameters bit_alloc; ///< bit allocation parameters - int coarse_snr_offset; ///< coarse SNR offsets (csnroffst) - int fast_gain_code[AC3_MAX_CHANNELS]; ///< fast gain codes (signal-to-mask ratio) (fgaincod) - int fine_snr_offset[AC3_MAX_CHANNELS]; ///< fine SNR offsets (fsnroffst) - int frame_bits_fixed; ///< number of non-coefficient bits for fixed parameters - int frame_bits; ///< all frame bits except exponents and mantissas - int exponent_bits; ///< number of bits used for exponents - - SampleType **planar_samples; - uint8_t *bap_buffer; - uint8_t *bap1_buffer; - CoefType *mdct_coef_buffer; - int32_t *fixed_coef_buffer; - uint8_t *exp_buffer; - uint8_t *grouped_exp_buffer; - int16_t *psd_buffer; - int16_t *band_psd_buffer; - int16_t *mask_buffer; - uint16_t *qmant_buffer; - uint8_t *cpl_coord_exp_buffer; - uint8_t *cpl_coord_mant_buffer; - - uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies - uint8_t exp_ref_block[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< reference blocks for EXP_REUSE - uint8_t *ref_bap [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap) - int ref_bap_set; ///< indicates if ref_bap pointers have been set - - DECLARE_ALIGNED(32, SampleType, windowed_samples)[AC3_WINDOW_SIZE]; -} AC3EncodeContext; +#include "ac3enc.h" +#include "eac3enc.h" typedef struct AC3Mant { uint16_t *qmant1_ptr, *qmant2_ptr, *qmant4_ptr; ///< mantissa pointers for bap=1,2,4 @@ -741,34 +566,8 @@ static void apply_channel_coupling(AC3EncodeContext *s) } } - if (s->eac3) { - /* set first cpl coords */ - int first_cpl_coords[AC3_MAX_CHANNELS]; - for (ch = 1; ch <= s->fbw_channels; ch++) - first_cpl_coords[ch] = 1; - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { - AC3Block *block = &s->blocks[blk]; - for (ch = 1; ch <= s->fbw_channels; ch++) { - if (block->channel_in_cpl[ch]) { - if (first_cpl_coords[ch]) { - block->new_cpl_coords = 2; - first_cpl_coords[ch] = 0; - } - } else { - first_cpl_coords[ch] = 1; - } - } - } - - /* set first cpl leak */ - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { - AC3Block *block = &s->blocks[blk]; - if (block->cpl_in_use) { - block->new_cpl_leak = 2; - break; - } - } - } + if (s->eac3) + ff_eac3_set_cpl_states(s); #endif /* CONFIG_AC3ENC_FLOAT */ } @@ -1905,79 +1704,6 @@ static void ac3_output_frame_header(AC3EncodeContext *s) } -/** - * Write the E-AC-3 frame header to the output bitstream. - */ -static void eac3_output_frame_header(AC3EncodeContext *s) -{ - int blk, ch; - AC3EncOptions *opt = &s->options; - - put_bits(&s->pb, 16, 0x0b77); /* sync word */ - - /* BSI header */ - put_bits(&s->pb, 2, 0); /* stream type = independent */ - put_bits(&s->pb, 3, 0); /* substream id = 0 */ - put_bits(&s->pb, 11, (s->frame_size / 2) - 1); /* frame size */ - if (s->bit_alloc.sr_shift) { - put_bits(&s->pb, 2, 0x3); /* fscod2 */ - put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ - } else { - put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ - put_bits(&s->pb, 2, 0x3); /* number of blocks = 6 */ - } - put_bits(&s->pb, 3, s->channel_mode); /* audio coding mode */ - put_bits(&s->pb, 1, s->lfe_on); /* LFE channel indicator */ - put_bits(&s->pb, 5, s->bitstream_id); /* bitstream id (EAC3=16) */ - put_bits(&s->pb, 5, -opt->dialogue_level); /* dialogue normalization level */ - put_bits(&s->pb, 1, 0); /* no compression gain */ - put_bits(&s->pb, 1, 0); /* no mixing metadata */ - /* TODO: mixing metadata */ - put_bits(&s->pb, 1, 0); /* no info metadata */ - /* TODO: info metadata */ - put_bits(&s->pb, 1, 0); /* no additional bit stream info */ - - /* frame header */ - put_bits(&s->pb, 1, 1); /* exponent strategy syntax = each block */ - put_bits(&s->pb, 1, 0); /* aht enabled = no */ - put_bits(&s->pb, 2, 0); /* snr offset strategy = 1 */ - put_bits(&s->pb, 1, 0); /* transient pre-noise processing enabled = no */ - put_bits(&s->pb, 1, 0); /* block switch syntax enabled = no */ - put_bits(&s->pb, 1, 0); /* dither flag syntax enabled = no */ - put_bits(&s->pb, 1, 0); /* bit allocation model syntax enabled = no */ - put_bits(&s->pb, 1, 0); /* fast gain codes enabled = no */ - put_bits(&s->pb, 1, 0); /* dba syntax enabled = no */ - put_bits(&s->pb, 1, 0); /* skip field syntax enabled = no */ - put_bits(&s->pb, 1, 0); /* spx enabled = no */ - /* coupling strategy use flags */ - if (s->channel_mode > AC3_CHMODE_MONO) { - put_bits(&s->pb, 1, s->blocks[0].cpl_in_use); - for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) { - AC3Block *block = &s->blocks[blk]; - put_bits(&s->pb, 1, block->new_cpl_strategy); - if (block->new_cpl_strategy) - put_bits(&s->pb, 1, block->cpl_in_use); - } - } - /* exponent strategy */ - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) - for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) - put_bits(&s->pb, 2, s->exp_strategy[ch][blk]); - if (s->lfe_on) { - for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) - put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]); - } - /* E-AC-3 to AC-3 converter exponent strategy (unfortunately not optional...) */ - for (ch = 1; ch <= s->fbw_channels; ch++) - put_bits(&s->pb, 5, 0); - /* snr offsets */ - put_bits(&s->pb, 6, s->coarse_snr_offset); - put_bits(&s->pb, 4, s->fine_snr_offset[1]); - /* block start info */ - put_bits(&s->pb, 1, 0); -} - - /** * Write one audio block to the output bitstream. */ @@ -2262,7 +1988,7 @@ static void output_frame(AC3EncodeContext *s, unsigned char *frame) init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE); if (s->eac3) - eac3_output_frame_header(s); + ff_eac3_output_frame_header(s); else ac3_output_frame_header(s); diff --git a/libavcodec/ac3enc.h b/libavcodec/ac3enc.h new file mode 100644 index 0000000000..0541683537 --- /dev/null +++ b/libavcodec/ac3enc.h @@ -0,0 +1,214 @@ +/* + * AC-3 encoder & E-AC-3 encoder common header + * Copyright (c) 2000 Fabrice Bellard + * Copyright (c) 2006-2010 Justin Ruggles + * + * 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 + */ + +/** + * @file + * AC-3 encoder & E-AC-3 encoder common header + */ + +#ifndef AVCODEC_AC3ENC_H +#define AVCODEC_AC3ENC_H + +#include +#include "ac3.h" +#include "ac3dsp.h" +#include "avcodec.h" +#include "dsputil.h" +#include "put_bits.h" +#include "fft.h" + +#ifndef CONFIG_AC3ENC_FLOAT +#define CONFIG_AC3ENC_FLOAT 0 +#endif + +#if CONFIG_AC3ENC_FLOAT +#define MAC_COEF(d,a,b) ((d)+=(a)*(b)) +typedef float SampleType; +typedef float CoefType; +typedef float CoefSumType; +#else +#define MAC_COEF(d,a,b) MAC64(d,a,b) +typedef int16_t SampleType; +typedef int32_t CoefType; +typedef int64_t CoefSumType; +#endif + +typedef struct AC3MDCTContext { + const SampleType *window; ///< MDCT window function + FFTContext fft; ///< FFT context for MDCT calculation +} AC3MDCTContext; + +/** + * Encoding Options used by AVOption. + */ +typedef struct AC3EncOptions { + /* AC-3 metadata options*/ + int dialogue_level; + int bitstream_mode; + float center_mix_level; + float surround_mix_level; + int dolby_surround_mode; + int audio_production_info; + int mixing_level; + int room_type; + int copyright; + int original; + int extended_bsi_1; + int preferred_stereo_downmix; + float ltrt_center_mix_level; + float ltrt_surround_mix_level; + float loro_center_mix_level; + float loro_surround_mix_level; + int extended_bsi_2; + int dolby_surround_ex_mode; + int dolby_headphone_mode; + int ad_converter_type; + + /* other encoding options */ + int allow_per_frame_metadata; + int stereo_rematrixing; + int channel_coupling; + int cpl_start; +} AC3EncOptions; + +/** + * Data for a single audio block. + */ +typedef struct AC3Block { + CoefType **mdct_coef; ///< MDCT coefficients + int32_t **fixed_coef; ///< fixed-point MDCT coefficients + uint8_t **exp; ///< original exponents + uint8_t **grouped_exp; ///< grouped exponents + int16_t **psd; ///< psd per frequency bin + int16_t **band_psd; ///< psd per critical band + int16_t **mask; ///< masking curve + uint16_t **qmant; ///< quantized mantissas + uint8_t **cpl_coord_exp; ///< coupling coord exponents (cplcoexp) + uint8_t **cpl_coord_mant; ///< coupling coord mantissas (cplcomant) + uint8_t coeff_shift[AC3_MAX_CHANNELS]; ///< fixed-point coefficient shift values + uint8_t new_rematrixing_strategy; ///< send new rematrixing flags in this block + int num_rematrixing_bands; ///< number of rematrixing bands + uint8_t rematrixing_flags[4]; ///< rematrixing flags + int new_cpl_strategy; ///< send new coupling strategy + int cpl_in_use; ///< coupling in use for this block (cplinu) + uint8_t channel_in_cpl[AC3_MAX_CHANNELS]; ///< channel in coupling (chincpl) + int num_cpl_channels; ///< number of channels in coupling + uint8_t new_cpl_coords; ///< send new coupling coordinates (cplcoe) + uint8_t cpl_master_exp[AC3_MAX_CHANNELS]; ///< coupling coord master exponents (mstrcplco) + int new_snr_offsets; ///< send new SNR offsets + int new_cpl_leak; ///< send new coupling leak info + int end_freq[AC3_MAX_CHANNELS]; ///< end frequency bin (endmant) +} AC3Block; + +/** + * AC-3 encoder private context. + */ +typedef struct AC3EncodeContext { + AVClass *av_class; ///< AVClass used for AVOption + AC3EncOptions options; ///< encoding options + PutBitContext pb; ///< bitstream writer context + DSPContext dsp; + AC3DSPContext ac3dsp; ///< AC-3 optimized functions + AC3MDCTContext mdct; ///< MDCT context + + AC3Block blocks[AC3_MAX_BLOCKS]; ///< per-block info + + int eac3; ///< indicates if this is E-AC-3 vs. AC-3 + int bitstream_id; ///< bitstream id (bsid) + int bitstream_mode; ///< bitstream mode (bsmod) + + int bit_rate; ///< target bit rate, in bits-per-second + int sample_rate; ///< sampling frequency, in Hz + + int frame_size_min; ///< minimum frame size in case rounding is necessary + int frame_size; ///< current frame size in bytes + int frame_size_code; ///< frame size code (frmsizecod) + uint16_t crc_inv[2]; + int64_t bits_written; ///< bit count (used to avg. bitrate) + int64_t samples_written; ///< sample count (used to avg. bitrate) + + int fbw_channels; ///< number of full-bandwidth channels (nfchans) + int channels; ///< total number of channels (nchans) + int lfe_on; ///< indicates if there is an LFE channel (lfeon) + int lfe_channel; ///< channel index of the LFE channel + int has_center; ///< indicates if there is a center channel + int has_surround; ///< indicates if there are one or more surround channels + int channel_mode; ///< channel mode (acmod) + const uint8_t *channel_map; ///< channel map used to reorder channels + + int center_mix_level; ///< center mix level code + int surround_mix_level; ///< surround mix level code + int ltrt_center_mix_level; ///< Lt/Rt center mix level code + int ltrt_surround_mix_level; ///< Lt/Rt surround mix level code + int loro_center_mix_level; ///< Lo/Ro center mix level code + int loro_surround_mix_level; ///< Lo/Ro surround mix level code + + int cutoff; ///< user-specified cutoff frequency, in Hz + int bandwidth_code; ///< bandwidth code (0 to 60) (chbwcod) + int start_freq[AC3_MAX_CHANNELS]; ///< start frequency bin (strtmant) + int cpl_end_freq; ///< coupling channel end frequency bin + + int cpl_on; ///< coupling turned on for this frame + int cpl_enabled; ///< coupling enabled for all frames + int num_cpl_subbands; ///< number of coupling subbands (ncplsubnd) + int num_cpl_bands; ///< number of coupling bands (ncplbnd) + uint8_t cpl_band_sizes[AC3_MAX_CPL_BANDS]; ///< number of coeffs in each coupling band + + int rematrixing_enabled; ///< stereo rematrixing enabled + + /* bitrate allocation control */ + int slow_gain_code; ///< slow gain code (sgaincod) + int slow_decay_code; ///< slow decay code (sdcycod) + int fast_decay_code; ///< fast decay code (fdcycod) + int db_per_bit_code; ///< dB/bit code (dbpbcod) + int floor_code; ///< floor code (floorcod) + AC3BitAllocParameters bit_alloc; ///< bit allocation parameters + int coarse_snr_offset; ///< coarse SNR offsets (csnroffst) + int fast_gain_code[AC3_MAX_CHANNELS]; ///< fast gain codes (signal-to-mask ratio) (fgaincod) + int fine_snr_offset[AC3_MAX_CHANNELS]; ///< fine SNR offsets (fsnroffst) + int frame_bits_fixed; ///< number of non-coefficient bits for fixed parameters + int frame_bits; ///< all frame bits except exponents and mantissas + int exponent_bits; ///< number of bits used for exponents + + SampleType **planar_samples; + uint8_t *bap_buffer; + uint8_t *bap1_buffer; + CoefType *mdct_coef_buffer; + int32_t *fixed_coef_buffer; + uint8_t *exp_buffer; + uint8_t *grouped_exp_buffer; + int16_t *psd_buffer; + int16_t *band_psd_buffer; + int16_t *mask_buffer; + uint16_t *qmant_buffer; + uint8_t *cpl_coord_exp_buffer; + uint8_t *cpl_coord_mant_buffer; + + uint8_t exp_strategy[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< exponent strategies + uint8_t exp_ref_block[AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< reference blocks for EXP_REUSE + uint8_t *ref_bap [AC3_MAX_CHANNELS][AC3_MAX_BLOCKS]; ///< bit allocation pointers (bap) + int ref_bap_set; ///< indicates if ref_bap pointers have been set + + DECLARE_ALIGNED(32, SampleType, windowed_samples)[AC3_WINDOW_SIZE]; +} AC3EncodeContext; + +#endif /* AVCODEC_AC3ENC_H */ diff --git a/libavcodec/eac3enc.c b/libavcodec/eac3enc.c new file mode 100644 index 0000000000..20f4b879c6 --- /dev/null +++ b/libavcodec/eac3enc.c @@ -0,0 +1,131 @@ +/* + * E-AC-3 encoder + * Copyright (c) 2011 Justin Ruggles + * + * 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 + */ + +/** + * @file + * E-AC-3 encoder + */ + +#define CONFIG_AC3ENC_FLOAT 1 +#include "ac3enc.h" +#include "eac3enc.h" + +void ff_eac3_set_cpl_states(AC3EncodeContext *s) +{ + int ch, blk; + int first_cpl_coords[AC3_MAX_CHANNELS]; + + /* set first cpl coords */ + for (ch = 1; ch <= s->fbw_channels; ch++) + first_cpl_coords[ch] = 1; + for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + AC3Block *block = &s->blocks[blk]; + for (ch = 1; ch <= s->fbw_channels; ch++) { + if (block->channel_in_cpl[ch]) { + if (first_cpl_coords[ch]) { + block->new_cpl_coords = 2; + first_cpl_coords[ch] = 0; + } + } else { + first_cpl_coords[ch] = 1; + } + } + } + + /* set first cpl leak */ + for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) { + AC3Block *block = &s->blocks[blk]; + if (block->cpl_in_use) { + block->new_cpl_leak = 2; + break; + } + } +} + + +void ff_eac3_output_frame_header(AC3EncodeContext *s) +{ + int blk, ch; + AC3EncOptions *opt = &s->options; + + put_bits(&s->pb, 16, 0x0b77); /* sync word */ + + /* BSI header */ + put_bits(&s->pb, 2, 0); /* stream type = independent */ + put_bits(&s->pb, 3, 0); /* substream id = 0 */ + put_bits(&s->pb, 11, (s->frame_size / 2) - 1); /* frame size */ + if (s->bit_alloc.sr_shift) { + put_bits(&s->pb, 2, 0x3); /* fscod2 */ + put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ + } else { + put_bits(&s->pb, 2, s->bit_alloc.sr_code); /* sample rate code */ + put_bits(&s->pb, 2, 0x3); /* number of blocks = 6 */ + } + put_bits(&s->pb, 3, s->channel_mode); /* audio coding mode */ + put_bits(&s->pb, 1, s->lfe_on); /* LFE channel indicator */ + put_bits(&s->pb, 5, s->bitstream_id); /* bitstream id (EAC3=16) */ + put_bits(&s->pb, 5, -opt->dialogue_level); /* dialogue normalization level */ + put_bits(&s->pb, 1, 0); /* no compression gain */ + put_bits(&s->pb, 1, 0); /* no mixing metadata */ + /* TODO: mixing metadata */ + put_bits(&s->pb, 1, 0); /* no info metadata */ + /* TODO: info metadata */ + put_bits(&s->pb, 1, 0); /* no additional bit stream info */ + + /* frame header */ + put_bits(&s->pb, 1, 1); /* exponent strategy syntax = each block */ + put_bits(&s->pb, 1, 0); /* aht enabled = no */ + put_bits(&s->pb, 2, 0); /* snr offset strategy = 1 */ + put_bits(&s->pb, 1, 0); /* transient pre-noise processing enabled = no */ + put_bits(&s->pb, 1, 0); /* block switch syntax enabled = no */ + put_bits(&s->pb, 1, 0); /* dither flag syntax enabled = no */ + put_bits(&s->pb, 1, 0); /* bit allocation model syntax enabled = no */ + put_bits(&s->pb, 1, 0); /* fast gain codes enabled = no */ + put_bits(&s->pb, 1, 0); /* dba syntax enabled = no */ + put_bits(&s->pb, 1, 0); /* skip field syntax enabled = no */ + put_bits(&s->pb, 1, 0); /* spx enabled = no */ + /* coupling strategy use flags */ + if (s->channel_mode > AC3_CHMODE_MONO) { + put_bits(&s->pb, 1, s->blocks[0].cpl_in_use); + for (blk = 1; blk < AC3_MAX_BLOCKS; blk++) { + AC3Block *block = &s->blocks[blk]; + put_bits(&s->pb, 1, block->new_cpl_strategy); + if (block->new_cpl_strategy) + put_bits(&s->pb, 1, block->cpl_in_use); + } + } + /* exponent strategy */ + for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) + for (ch = !s->blocks[blk].cpl_in_use; ch <= s->fbw_channels; ch++) + put_bits(&s->pb, 2, s->exp_strategy[ch][blk]); + if (s->lfe_on) { + for (blk = 0; blk < AC3_MAX_BLOCKS; blk++) + put_bits(&s->pb, 1, s->exp_strategy[s->lfe_channel][blk]); + } + /* E-AC-3 to AC-3 converter exponent strategy (unfortunately not optional...) */ + for (ch = 1; ch <= s->fbw_channels; ch++) + put_bits(&s->pb, 5, 0); + /* snr offsets */ + put_bits(&s->pb, 6, s->coarse_snr_offset); + put_bits(&s->pb, 4, s->fine_snr_offset[1]); + /* block start info */ + put_bits(&s->pb, 1, 0); +} diff --git a/libavcodec/eac3enc.h b/libavcodec/eac3enc.h new file mode 100644 index 0000000000..eacb8cf164 --- /dev/null +++ b/libavcodec/eac3enc.h @@ -0,0 +1,44 @@ +/* + * E-AC-3 encoder + * Copyright (c) 2011 Justin Ruggles + * + * 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 + */ + +/** + * @file + * E-AC-3 encoder + */ + +#ifndef AVCODEC_EAC3ENC_H +#define AVCODEC_EAC3ENC_H + +#include "ac3enc.h" + +/** + * Set coupling states. + * This determines whether certain flags must be written to the bitstream or + * whether they will be implicitly already known by the decoder. + */ +void ff_eac3_set_cpl_states(AC3EncodeContext *s); + +/** + * Write the E-AC-3 frame header to the output bitstream. + */ +void ff_eac3_output_frame_header(AC3EncodeContext *s); + +#endif /* AVCODEC_EAC3ENC_H */ -- cgit v1.2.3 From d3778972d854b72685b10e0b4afedcc1af6f5433 Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 8 Jun 2011 00:06:19 +0200 Subject: ac3enc: Fix linking of AC-3 encoder without the E-AC-3 encoder. The AC-3 encoder unconditionally references some symbols from the E-AC-3 encoder; make those references conditional to fix linking. --- libavcodec/ac3enc.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/libavcodec/ac3enc.c b/libavcodec/ac3enc.c index 9e011af094..e8ccde514a 100644 --- a/libavcodec/ac3enc.c +++ b/libavcodec/ac3enc.c @@ -566,7 +566,7 @@ static void apply_channel_coupling(AC3EncodeContext *s) } } - if (s->eac3) + if (CONFIG_EAC3_ENCODER && s->eac3) ff_eac3_set_cpl_states(s); #endif /* CONFIG_AC3ENC_FLOAT */ } @@ -1987,7 +1987,7 @@ static void output_frame(AC3EncodeContext *s, unsigned char *frame) init_put_bits(&s->pb, frame, AC3_MAX_CODED_FRAME_SIZE); - if (s->eac3) + if (CONFIG_EAC3_ENCODER && s->eac3) ff_eac3_output_frame_header(s); else ac3_output_frame_header(s); -- cgit v1.2.3 From 4de83b7b6d3ba321877f69621ef0de497384060c Mon Sep 17 00:00:00 2001 From: Daniel Kang Date: Tue, 7 Jun 2011 10:31:51 -0400 Subject: H264: x86 predict init cosmetics. Change indentation and whitespace; also move HAVE_YASM blocks. Signed-off-by: Diego Biurrun --- libavcodec/x86/h264_intrapred_init.c | 220 +++++++++++++++++------------------ 1 file changed, 110 insertions(+), 110 deletions(-) diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c index da5553571a..9d6726c31c 100644 --- a/libavcodec/x86/h264_intrapred_init.c +++ b/libavcodec/x86/h264_intrapred_init.c @@ -124,132 +124,132 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth { int mm_flags = av_get_cpu_flags(); - if (bit_depth == 8) { #if HAVE_YASM - if (mm_flags & AV_CPU_FLAG_MMX) { - h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_mmx; - h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx; - h->pred8x8 [VERT_PRED8x8] = ff_pred8x8_vertical_mmx; - h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx; - if (codec_id == CODEC_ID_VP8) { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmx; - h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmx; - h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx; - } else { - h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx; - if (codec_id == CODEC_ID_SVQ3) { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx; - } else if (codec_id == CODEC_ID_RV40) { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx; + if (bit_depth == 8) { + if (mm_flags & AV_CPU_FLAG_MMX) { + h->pred16x16[VERT_PRED8x8 ] = ff_pred16x16_vertical_mmx; + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmx; + h->pred8x8 [VERT_PRED8x8 ] = ff_pred8x8_vertical_mmx; + h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmx; + if (codec_id == CODEC_ID_VP8) { + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmx; + h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_mmx; + h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmx; } else { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx; + h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx; + if (codec_id == CODEC_ID_SVQ3) { + h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx; + } else if (codec_id == CODEC_ID_RV40) { + h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx; + } else { + h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx; + } } } - } - if (mm_flags & AV_CPU_FLAG_MMX2) { - h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext; - h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext; - h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext; - h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext; - h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext; - h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext; - h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_mmxext; - h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_mmxext; - h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_mmxext; - h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_mmxext; - h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext; - h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_mmxext; - h->pred4x4 [DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_mmxext; - h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_mmxext; - h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_mmxext; - h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext; - if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264) - h->pred4x4 [DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_mmxext; - if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) - h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_mmxext; - if (codec_id != CODEC_ID_RV40) { - h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext; - } - if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) { - h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext; - h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext; - } - if (codec_id == CODEC_ID_VP8) { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext; - h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext; - h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_mmxext; - h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext; - h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext; - } else { - h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2; - if (codec_id == CODEC_ID_SVQ3) { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_mmx2; - } else if (codec_id == CODEC_ID_RV40) { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_mmx2; + if (mm_flags & AV_CPU_FLAG_MMX2) { + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext; + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext; + h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext; + h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_mmxext; + h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_mmxext; + h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_mmxext; + h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_mmxext; + h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_mmxext; + h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_mmxext; + h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_mmxext; + h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_mmxext; + h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_mmxext; + h->pred4x4 [DIAG_DOWN_RIGHT_PRED ] = ff_pred4x4_down_right_mmxext; + h->pred4x4 [VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_mmxext; + h->pred4x4 [HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_mmxext; + h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext; + if (codec_id == CODEC_ID_VP8 || codec_id == CODEC_ID_H264) { + h->pred4x4 [DIAG_DOWN_LEFT_PRED] = ff_pred4x4_down_left_mmxext; + } + if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) { + h->pred4x4 [VERT_LEFT_PRED ] = ff_pred4x4_vertical_left_mmxext; + } + if (codec_id != CODEC_ID_RV40) { + h->pred4x4 [HOR_UP_PRED ] = ff_pred4x4_horizontal_up_mmxext; + } + if (codec_id == CODEC_ID_SVQ3 || codec_id == CODEC_ID_H264) { + h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext; + h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext; + } + if (codec_id == CODEC_ID_VP8) { + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_mmxext; + h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext; + h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_mmxext; + h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_mmxext; + h->pred4x4 [VERT_PRED ] = ff_pred4x4_vertical_vp8_mmxext; } else { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_mmx2; + h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_mmx2; + if (codec_id == CODEC_ID_SVQ3) { + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_svq3_mmx2; + } else if (codec_id == CODEC_ID_RV40) { + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_rv40_mmx2; + } else { + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_plane_h264_mmx2; + } } } - } - if (mm_flags & AV_CPU_FLAG_SSE) { - h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse; - } + if (mm_flags & AV_CPU_FLAG_SSE) { + h->pred16x16[VERT_PRED8x8] = ff_pred16x16_vertical_sse; + } - if (mm_flags & AV_CPU_FLAG_SSE2) { - h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2; - h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2; - h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_sse2; - h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_sse2; - h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_sse2; - h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_sse2; - if (codec_id == CODEC_ID_VP8) { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2; - h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2; - } else { - h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_sse2; - if (codec_id == CODEC_ID_SVQ3) { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2; - } else if (codec_id == CODEC_ID_RV40) { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_sse2; + if (mm_flags & AV_CPU_FLAG_SSE2) { + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2; + h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_sse2; + h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_sse2; + h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_sse2; + h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_sse2; + h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_sse2; + if (codec_id == CODEC_ID_VP8) { + h->pred16x16[PLANE_PRED8x8 ] = ff_pred16x16_tm_vp8_sse2; + h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_sse2; } else { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_sse2; + h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_plane_sse2; + if (codec_id == CODEC_ID_SVQ3) { + h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_sse2; + } else if (codec_id == CODEC_ID_RV40) { + h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_sse2; + } else { + h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_sse2; + } } } - } - if (mm_flags & AV_CPU_FLAG_SSSE3) { - h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3; - h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3; - h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3; - h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3; - h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3; - h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3; - h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_ssse3; - h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3; - h->pred8x8l [DIAG_DOWN_RIGHT_PRED] = ff_pred8x8l_down_right_ssse3; - h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_ssse3; - h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_ssse3; - h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_ssse3; - h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_ssse3; - if (codec_id == CODEC_ID_VP8) { - h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_ssse3; - h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3; - } else { - h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3; - if (codec_id == CODEC_ID_SVQ3) { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3; - } else if (codec_id == CODEC_ID_RV40) { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_ssse3; + if (mm_flags & AV_CPU_FLAG_SSSE3) { + h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3; + h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3; + h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3; + h->pred8x8l [TOP_DC_PRED ] = ff_pred8x8l_top_dc_ssse3; + h->pred8x8l [DC_PRED ] = ff_pred8x8l_dc_ssse3; + h->pred8x8l [HOR_PRED ] = ff_pred8x8l_horizontal_ssse3; + h->pred8x8l [VERT_PRED ] = ff_pred8x8l_vertical_ssse3; + h->pred8x8l [DIAG_DOWN_LEFT_PRED ] = ff_pred8x8l_down_left_ssse3; + h->pred8x8l [DIAG_DOWN_RIGHT_PRED ] = ff_pred8x8l_down_right_ssse3; + h->pred8x8l [VERT_RIGHT_PRED ] = ff_pred8x8l_vertical_right_ssse3; + h->pred8x8l [VERT_LEFT_PRED ] = ff_pred8x8l_vertical_left_ssse3; + h->pred8x8l [HOR_UP_PRED ] = ff_pred8x8l_horizontal_up_ssse3; + h->pred8x8l [HOR_DOWN_PRED ] = ff_pred8x8l_horizontal_down_ssse3; + if (codec_id == CODEC_ID_VP8) { + h->pred8x8 [PLANE_PRED8x8 ] = ff_pred8x8_tm_vp8_ssse3; + h->pred4x4 [TM_VP8_PRED ] = ff_pred4x4_tm_vp8_ssse3; } else { - h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_ssse3; + h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_plane_ssse3; + if (codec_id == CODEC_ID_SVQ3) { + h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_svq3_ssse3; + } else if (codec_id == CODEC_ID_RV40) { + h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_rv40_ssse3; + } else { + h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_plane_h264_ssse3; + } } } - } -#endif } else if (bit_depth == 10) { -#if HAVE_YASM if (mm_flags & AV_CPU_FLAG_MMX2) { h->pred4x4[DC_PRED ] = ff_pred4x4_dc_10_mmxext; h->pred4x4[HOR_UP_PRED ] = ff_pred4x4_horizontal_up_10_mmxext; @@ -270,13 +270,13 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_ssse3; } #if HAVE_AVX - if (mm_flags&AV_CPU_FLAG_AVX) { + if (mm_flags & AV_CPU_FLAG_AVX) { h->pred4x4[DIAG_DOWN_LEFT_PRED ] = ff_pred4x4_down_left_10_avx; h->pred4x4[DIAG_DOWN_RIGHT_PRED] = ff_pred4x4_down_right_10_avx; h->pred4x4[VERT_RIGHT_PRED ] = ff_pred4x4_vertical_right_10_avx; h->pred4x4[HOR_DOWN_PRED ] = ff_pred4x4_horizontal_down_10_avx; } #endif /* HAVE_AVX */ -#endif /* HAVE_YASM */ } +#endif /* HAVE_YASM */ } -- cgit v1.2.3 From 8543f0f923eb1d476b14444e1cc8034f08ebcdda Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Wed, 8 Jun 2011 00:41:12 +0200 Subject: ffplay: Fix non-compiling debug printf and replace it by av_dlog. --- ffplay.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/ffplay.c b/ffplay.c index 4ccad0618d..5700883828 100644 --- a/ffplay.c +++ b/ffplay.c @@ -1062,10 +1062,9 @@ static double compute_target_time(double frame_current_pts, VideoState *is) } } is->frame_timer += delay; -#if defined(DEBUG_SYNC) - printf("video: delay=%0.3f actual_delay=%0.3f pts=%0.3f A-V=%f\n", - delay, actual_delay, frame_current_pts, -diff); -#endif + + av_dlog(NULL, "video: delay=%0.3f pts=%0.3f A-V=%f\n", + delay, frame_current_pts, -diff); return is->frame_timer; } -- cgit v1.2.3 From ac4a8548110bc180cb67bea6eaf8b8e1081370cf Mon Sep 17 00:00:00 2001 From: Diego Biurrun Date: Sun, 5 Jun 2011 15:53:34 +0200 Subject: Remove some non-compiling debug messages. --- libavcodec/motion_est.c | 2 -- libavformat/mpeg.c | 3 --- 2 files changed, 5 deletions(-) diff --git a/libavcodec/motion_est.c b/libavcodec/motion_est.c index 4d4377be6a..5f10456d3b 100644 --- a/libavcodec/motion_est.c +++ b/libavcodec/motion_est.c @@ -1119,8 +1119,6 @@ void ff_estimate_p_frame_motion(MpegEncContext * s, // pic->mb_cmp_score[s->mb_stride * mb_y + mb_x] = dmin; c->mc_mb_var_sum_temp += (vard+128)>>8; - av_dlog(s, "varc=%4d avg_var=%4d (sum=%4d) vard=%4d mx=%2d my=%2d\n", - varc, s->avg_mb_var, sum, vard, mx - xx, my - yy); if(mb_type){ int p_score= FFMIN(vard, varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*100); int i_score= varc-500+(s->lambda2>>FF_LAMBDA_SHIFT)*20; diff --git a/libavformat/mpeg.c b/libavformat/mpeg.c index 86cee0c4b8..5b4996e825 100644 --- a/libavformat/mpeg.c +++ b/libavformat/mpeg.c @@ -583,9 +583,6 @@ static int64_t mpegps_read_dts(AVFormatContext *s, int stream_index, int64_t pos, pts, dts; pos = *ppos; -#ifdef DEBUG_SEEK - printf("read_dts: pos=0x%"PRIx64" next=%d -> ", pos, find_next); -#endif if (avio_seek(s->pb, pos, SEEK_SET) < 0) return AV_NOPTS_VALUE; -- cgit v1.2.3