aboutsummaryrefslogtreecommitdiffstats
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2011-06-03 05:19:30 +0200
committerMichael Niedermayer <michaelni@gmx.at>2011-06-03 05:19:30 +0200
commit99eb31e263a24bc6c5a7a3f455a2bcb04a60e70e (patch)
tree83aab2f083fd3d6923d4e76fe0cc0c41ef7aef35 /libavcodec
parent9034001b17077e9da5205c4344eb1b88b9882f03 (diff)
parentf190f676bc93a7e80344f2feeb3b9b44604d4717 (diff)
downloadffmpeg-99eb31e263a24bc6c5a7a3f455a2bcb04a60e70e.tar.gz
Merge remote-tracking branch 'qatar/master'
* qatar/master: (25 commits) Replace custom DEBUG preprocessor trickery by the standard one. vorbis: Remove non-compiling debug statement. vorbis: Remove pointless DEBUG #ifdef around debug output macros. cook: Remove non-compiling debug output. Remove pointless #ifdefs around function declarations in a header. Replace #ifdef + av_log() combinations by av_dlog(). Replace custom debug output functions by av_dlog(). cook: Remove unused debug functions. Remove stray extra arguments from av_dlog() invocations. targa: fix big-endian build v4l2: remove one forgotten use of AVFormatParameters.pix_fmt. vfwcap: add a framerate private option. v4l2: add a framerate private option. libdc1394: add a framerate private option. fbdev: add a framerate private option. bktr: add a framerate private option. oma: check avio_read() return value nutdec: remove unused variable Remove unused variables swscale: allocate larger buffer to handle altivec overreads. ... Conflicts: ffmpeg.c libavcodec/dca.c libavcodec/dirac.c libavcodec/error_resilience.c libavcodec/h264.c libavcodec/mpeg12.c libavcodec/mpeg4videodec.c libavcodec/mpegvideo.c libavcodec/mpegvideo_enc.c libavcodec/pthread.c libavcodec/rv10.c libavcodec/s302m.c libavcodec/shorten.c libavcodec/truemotion2.c libavcodec/utils.c libavdevice/dv1394.c libavdevice/fbdev.c libavdevice/libdc1394.c libavdevice/v4l2.c libavformat/4xm.c libavformat/apetag.c libavformat/asfdec.c libavformat/avidec.c libavformat/mmf.c libavformat/mpeg.c libavformat/mpegenc.c libavformat/mpegts.c libavformat/oggdec.c libavformat/oggparseogm.c libavformat/rl2.c libavformat/rmdec.c libavformat/rpl.c libavformat/rtpdec_latm.c libavformat/sauce.c libavformat/sol.c libswscale/utils.c tests/ref/vsynth1/error tests/ref/vsynth2/error Merged-by: Michael Niedermayer <michaelni@gmx.at>
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/aaccoder.c9
-rw-r--r--libavcodec/aacenc.c32
-rw-r--r--libavcodec/aacenc.h6
-rw-r--r--libavcodec/cook.c38
-rw-r--r--libavcodec/dca.c6
-rw-r--r--libavcodec/dirac.c4
-rw-r--r--libavcodec/error_resilience.c45
-rw-r--r--libavcodec/h263dec.c3
-rw-r--r--libavcodec/h264.c152
-rw-r--r--libavcodec/indeo5.c2
-rw-r--r--libavcodec/interplayvideo.c24
-rw-r--r--libavcodec/ituh263dec.c6
-rw-r--r--libavcodec/ivi_common.c6
-rw-r--r--libavcodec/ivi_common.h4
-rw-r--r--libavcodec/mpeg12.c11
-rw-r--r--libavcodec/mpeg12enc.c3
-rw-r--r--libavcodec/mpeg4videodec.c19
-rw-r--r--libavcodec/mpegvideo.c8
-rw-r--r--libavcodec/mpegvideo.h2
-rw-r--r--libavcodec/mpegvideo_enc.c2
-rw-r--r--libavcodec/mpegvideo_parser.c3
-rw-r--r--libavcodec/msmpeg4.c4
-rw-r--r--libavcodec/pngdec.c13
-rw-r--r--libavcodec/pthread.c2
-rw-r--r--libavcodec/rv10.c4
-rw-r--r--libavcodec/s302m.c3
-rw-r--r--libavcodec/shorten.c3
-rw-r--r--libavcodec/svq1dec.c34
-rw-r--r--libavcodec/targa.c7
-rw-r--r--libavcodec/truemotion2.c13
-rw-r--r--libavcodec/tscc.c3
-rw-r--r--libavcodec/utils.c2
-rw-r--r--libavcodec/vorbis.c9
-rw-r--r--libavcodec/vorbisdec.c216
-rw-r--r--libavcodec/vqavideo.c20
-rw-r--r--libavcodec/x86/h264_idct_10bit.asm178
-rw-r--r--libavcodec/x86/h264_intrapred.asm6
-rw-r--r--libavcodec/x86/h264_intrapred_init.c8
38 files changed, 490 insertions, 420 deletions
diff --git a/libavcodec/aaccoder.c b/libavcodec/aaccoder.c
index 187b4ad972..a68aa025de 100644
--- a/libavcodec/aaccoder.c
+++ b/libavcodec/aaccoder.c
@@ -312,7 +312,7 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce
int win, int group_len, const float lambda)
{
BandCodingPath path[120][12];
- int w, swb, cb, start, start2, size;
+ int w, swb, cb, start, size;
int i, j;
const int max_sfb = sce->ics.max_sfb;
const int run_bits = sce->ics.num_windows == 1 ? 5 : 3;
@@ -330,7 +330,6 @@ static void encode_window_bands_info(AACEncContext *s, SingleChannelElement *sce
path[0][cb].run = 0;
}
for (swb = 0; swb < max_sfb; swb++) {
- start2 = start;
size = sce->ics.swb_sizes[swb];
if (sce->zeroes[win*16 + swb]) {
for (cb = 0; cb < 12; cb++) {
@@ -414,7 +413,7 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce,
int win, int group_len, const float lambda)
{
BandCodingPath path[120][12];
- int w, swb, cb, start, start2, size;
+ int w, swb, cb, start, size;
int i, j;
const int max_sfb = sce->ics.max_sfb;
const int run_bits = sce->ics.num_windows == 1 ? 5 : 3;
@@ -432,7 +431,6 @@ static void codebook_trellis_rate(AACEncContext *s, SingleChannelElement *sce,
path[0][cb].run = 0;
}
for (swb = 0; swb < max_sfb; swb++) {
- start2 = start;
size = sce->ics.swb_sizes[swb];
if (sce->zeroes[win*16 + swb]) {
for (cb = 0; cb < 12; cb++) {
@@ -1007,12 +1005,11 @@ static void search_for_quantizers_fast(AVCodecContext *avctx, AACEncContext *s,
SingleChannelElement *sce,
const float lambda)
{
- int start = 0, i, w, w2, g;
+ int i, w, w2, g;
int minq = 255;
memset(sce->sf_idx, 0, sizeof(sce->sf_idx));
for (w = 0; w < sce->ics.num_windows; w += sce->ics.group_len[w]) {
- start = w*128;
for (g = 0; g < sce->ics.num_swb; g++) {
for (w2 = 0; w2 < sce->ics.group_len[w]; w2++) {
FFPsyBand *band = &s->psy.psy_bands[s->cur_channel*PSY_MAX_BANDS+(w+w2)*16+g];
diff --git a/libavcodec/aacenc.c b/libavcodec/aacenc.c
index b51fccded3..66af2b1915 100644
--- a/libavcodec/aacenc.c
+++ b/libavcodec/aacenc.c
@@ -30,6 +30,7 @@
* add temporal noise shaping
***********************************/
+#include "libavutil/opt.h"
#include "avcodec.h"
#include "put_bits.h"
#include "dsputil.h"
@@ -489,7 +490,7 @@ static int aac_encode_frame(AVCodecContext *avctx,
AACEncContext *s = avctx->priv_data;
int16_t *samples = s->samples, *samples2, *la;
ChannelElement *cpe;
- int i, ch, w, chans, tag, start_ch;
+ int i, ch, w, g, chans, tag, start_ch;
const uint8_t *chan_map = aac_chan_configs[avctx->channels-1];
int chan_el_counter[4];
FFPsyWindowInfo windows[AAC_MAX_CHANNELS];
@@ -587,8 +588,16 @@ static int aac_encode_frame(AVCodecContext *avctx,
}
}
s->cur_channel = start_ch;
- if (cpe->common_window && s->coder->search_for_ms)
- s->coder->search_for_ms(s, cpe, s->lambda);
+ if (s->options.stereo_mode && cpe->common_window) {
+ if (s->options.stereo_mode > 0) {
+ IndividualChannelStream *ics = &cpe->ch[0].ics;
+ for (w = 0; w < ics->num_windows; w += ics->group_len[w])
+ for (g = 0; g < ics->num_swb; g++)
+ cpe->ms_mask[w*16+g] = 1;
+ } else if (s->coder->search_for_ms) {
+ s->coder->search_for_ms(s, cpe, s->lambda);
+ }
+ }
adjust_frame_information(s, cpe, chans);
if (chans == 2) {
put_bits(&s->pb, 1, cpe->common_window);
@@ -645,6 +654,22 @@ static av_cold int aac_encode_end(AVCodecContext *avctx)
return 0;
}
+#define AACENC_FLAGS AV_OPT_FLAG_ENCODING_PARAM | AV_OPT_FLAG_AUDIO_PARAM
+static const AVOption aacenc_options[] = {
+ {"stereo_mode", "Stereo coding method", offsetof(AACEncContext, options.stereo_mode), FF_OPT_TYPE_INT, {.dbl = 0}, -1, 1, AACENC_FLAGS, "stereo_mode"},
+ {"auto", "Selected by the Encoder", 0, FF_OPT_TYPE_CONST, {.dbl = -1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"},
+ {"ms_off", "Disable Mid/Side coding", 0, FF_OPT_TYPE_CONST, {.dbl = 0 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"},
+ {"ms_force", "Force Mid/Side for the whole frame if possible", 0, FF_OPT_TYPE_CONST, {.dbl = 1 }, INT_MIN, INT_MAX, AACENC_FLAGS, "stereo_mode"},
+ {NULL}
+};
+
+static const AVClass aacenc_class = {
+ "AAC encoder",
+ av_default_item_name,
+ aacenc_options,
+ LIBAVUTIL_VERSION_INT,
+};
+
AVCodec ff_aac_encoder = {
"aac",
AVMEDIA_TYPE_AUDIO,
@@ -656,4 +681,5 @@ AVCodec ff_aac_encoder = {
.capabilities = CODEC_CAP_SMALL_LAST_FRAME | CODEC_CAP_DELAY | CODEC_CAP_EXPERIMENTAL,
.sample_fmts = (const enum AVSampleFormat[]){AV_SAMPLE_FMT_S16,AV_SAMPLE_FMT_NONE},
.long_name = NULL_IF_CONFIG_SMALL("Advanced Audio Coding"),
+ .priv_class = &aacenc_class,
};
diff --git a/libavcodec/aacenc.h b/libavcodec/aacenc.h
index c12475a187..44ad50bf80 100644
--- a/libavcodec/aacenc.h
+++ b/libavcodec/aacenc.h
@@ -30,6 +30,10 @@
#include "psymodel.h"
+typedef struct AACEncOptions {
+ int stereo_mode;
+} AACEncOptions;
+
struct AACEncContext;
typedef struct AACCoefficientsEncoder {
@@ -48,6 +52,8 @@ extern AACCoefficientsEncoder ff_aac_coders[];
* AAC encoder context
*/
typedef struct AACEncContext {
+ AVClass *av_class;
+ AACEncOptions options; ///< encoding options
PutBitContext pb;
FFTContext mdct1024; ///< long (1024 samples) frame transform context
FFTContext mdct128; ///< short (128 samples) frame transform context
diff --git a/libavcodec/cook.c b/libavcodec/cook.c
index 249b966eaa..f0dee7905a 100644
--- a/libavcodec/cook.c
+++ b/libavcodec/cook.c
@@ -66,7 +66,6 @@
#define SUBBAND_SIZE 20
#define MAX_SUBPACKETS 5
-//#define COOKDEBUG
typedef struct {
int *now;
@@ -166,38 +165,6 @@ typedef struct cook {
static float pow2tab[127];
static float rootpow2tab[127];
-/* debug functions */
-
-#ifdef COOKDEBUG
-static void dump_float_table(float* table, int size, int delimiter) {
- int i=0;
- av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i);
- for (i=0 ; i<size ; i++) {
- av_log(NULL, AV_LOG_ERROR, "%5.1f, ", table[i]);
- if ((i+1)%delimiter == 0) av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i+1);
- }
-}
-
-static void dump_int_table(int* table, int size, int delimiter) {
- int i=0;
- av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i);
- for (i=0 ; i<size ; i++) {
- av_log(NULL, AV_LOG_ERROR, "%d, ", table[i]);
- if ((i+1)%delimiter == 0) av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i+1);
- }
-}
-
-static void dump_short_table(short* table, int size, int delimiter) {
- int i=0;
- av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i);
- for (i=0 ; i<size ; i++) {
- av_log(NULL, AV_LOG_ERROR, "%d, ", table[i]);
- if ((i+1)%delimiter == 0) av_log(NULL,AV_LOG_ERROR,"\n[%d]: ",i+1);
- }
-}
-
-#endif
-
/*************** init functions ***************/
/* table generator */
@@ -1037,7 +1004,7 @@ static int cook_decode_frame(AVCodecContext *avctx,
return avctx->block_align;
}
-#ifdef COOKDEBUG
+#ifdef DEBUG
static void dump_cook_context(COOKContext *q)
{
//int i=0;
@@ -1055,7 +1022,6 @@ static void dump_cook_context(COOKContext *q)
PRINT("samples_per_channel",q->subpacket[0].samples_per_channel);
PRINT("samples_per_frame",q->subpacket[0].samples_per_frame);
PRINT("subbands",q->subpacket[0].subbands);
- PRINT("random_state",q->random_state);
PRINT("js_subband_start",q->subpacket[0].js_subband_start);
PRINT("log2_numvector_size",q->subpacket[0].log2_numvector_size);
PRINT("numvector_size",q->subpacket[0].numvector_size);
@@ -1280,7 +1246,7 @@ static av_cold int cook_decode_init(AVCodecContext *avctx)
else
avctx->channel_layout = (avctx->channels==2) ? AV_CH_LAYOUT_STEREO : AV_CH_LAYOUT_MONO;
-#ifdef COOKDEBUG
+#ifdef DEBUG
dump_cook_context(q);
#endif
return 0;
diff --git a/libavcodec/dca.c b/libavcodec/dca.c
index 074f998995..0235a57a59 100644
--- a/libavcodec/dca.c
+++ b/libavcodec/dca.c
@@ -1535,8 +1535,6 @@ static void dca_exss_parse_header(DCAContext *s)
{
int ss_index;
int blownup;
- int header_size av_unused;
- int hd_size av_unused;
int num_audiop = 1;
int num_assets = 1;
int active_ss_mask[8];
@@ -1549,8 +1547,8 @@ static void dca_exss_parse_header(DCAContext *s)
ss_index = get_bits(&s->gb, 2);
blownup = get_bits1(&s->gb);
- header_size = get_bits(&s->gb, 8 + 4 * blownup) + 1;
- hd_size = get_bits_long(&s->gb, 16 + 4 * blownup) + 1;
+ skip_bits(&s->gb, 8 + 4 * blownup); // header_size
+ skip_bits(&s->gb, 16 + 4 * blownup); // hd_size
s->static_fields = get_bits1(&s->gb);
if (s->static_fields) {
diff --git a/libavcodec/dirac.c b/libavcodec/dirac.c
index f39e9996d6..af0d799acc 100644
--- a/libavcodec/dirac.c
+++ b/libavcodec/dirac.c
@@ -245,11 +245,11 @@ static int parse_source_parameters(AVCodecContext *avctx, GetBitContext *gb,
int ff_dirac_parse_sequence_header(AVCodecContext *avctx, GetBitContext *gb,
dirac_source_params *source)
{
- unsigned version_major, version_minor av_unused;
+ unsigned version_major;
unsigned video_format, picture_coding_mode;
version_major = svq3_get_ue_golomb(gb);
- version_minor = svq3_get_ue_golomb(gb);
+ svq3_get_ue_golomb(gb); /* version_minor */
avctx->profile = svq3_get_ue_golomb(gb);
avctx->level = svq3_get_ue_golomb(gb);
video_format = svq3_get_ue_golomb(gb);
diff --git a/libavcodec/error_resilience.c b/libavcodec/error_resilience.c
index c9231e206f..68e465796a 100644
--- a/libavcodec/error_resilience.c
+++ b/libavcodec/error_resilience.c
@@ -32,6 +32,7 @@
#include "mpegvideo.h"
#include "h264.h"
#include "rectangle.h"
+#include "thread.h"
/*
* H264 redefines mb_intra so it is not mistakely used (its uninitialized in h264)
@@ -436,8 +437,7 @@ int score_sum=0;
int best_score=256*256*256*64;
int best_pred=0;
const int mot_index= (mb_x + mb_y*mot_stride) * mot_step;
- int prev_x= s->current_picture.motion_val[0][mot_index][0];
- int prev_y= s->current_picture.motion_val[0][mot_index][1];
+ int prev_x, prev_y, prev_ref;
if((mb_x^mb_y^pass)&1) continue;
@@ -535,10 +535,26 @@ skip_mean_and_median:
/* zero MV */
pred_count++;
+ if (!fixed[mb_xy] && 0) {
+ if (s->avctx->codec_id == CODEC_ID_H264) {
+ // FIXME
+ } else {
+ ff_thread_await_progress((AVFrame *) s->last_picture_ptr,
+ mb_y, 0);
+ }
+ prev_x = s->last_picture.motion_val[0][mot_index][0];
+ prev_y = s->last_picture.motion_val[0][mot_index][1];
+ prev_ref = s->last_picture.ref_index[0][4*mb_xy];
+ } else {
+ prev_x = s->current_picture.motion_val[0][mot_index][0];
+ prev_y = s->current_picture.motion_val[0][mot_index][1];
+ prev_ref = s->current_picture.ref_index[0][4*mb_xy];
+ }
+
/* last MV */
- mv_predictor[pred_count][0]= s->current_picture.motion_val[0][mot_index][0];
- mv_predictor[pred_count][1]= s->current_picture.motion_val[0][mot_index][1];
- ref [pred_count] = s->current_picture.ref_index[0][4*mb_xy];
+ mv_predictor[pred_count][0]= prev_x;
+ mv_predictor[pred_count][1]= prev_y;
+ ref [pred_count] = prev_ref;
pred_count++;
s->mv_dir = MV_DIR_FORWARD;
@@ -670,6 +686,12 @@ static int is_intra_more_likely(MpegEncContext *s){
uint8_t *mb_ptr = s->current_picture.data[0] + mb_x*16 + mb_y*16*s->linesize;
uint8_t *last_mb_ptr= s->last_picture.data [0] + mb_x*16 + mb_y*16*s->linesize;
+ if (s->avctx->codec_id == CODEC_ID_H264) {
+ // FIXME
+ } else {
+ ff_thread_await_progress((AVFrame *) s->last_picture_ptr,
+ mb_y, 0);
+ }
is_intra_likely += s->dsp.sad[0](NULL, last_mb_ptr, mb_ptr , s->linesize, 16);
// FIXME need await_progress() here
is_intra_likely -= s->dsp.sad[0](NULL, last_mb_ptr, last_mb_ptr+s->linesize*16, s->linesize, 16);
@@ -690,6 +712,7 @@ void ff_er_frame_start(MpegEncContext *s){
memset(s->error_status_table, MV_ERROR|AC_ERROR|DC_ERROR|VP_START|AC_END|DC_END|MV_END, s->mb_stride*s->mb_height*sizeof(uint8_t));
s->error_count= 3*s->mb_num;
+ s->error_occurred = 0;
}
/**
@@ -729,7 +752,10 @@ void ff_er_add_slice(MpegEncContext *s, int startx, int starty, int endx, int en
s->error_count -= end_i - start_i + 1;
}
- if(status & (AC_ERROR|DC_ERROR|MV_ERROR)) s->error_count= INT_MAX;
+ if(status & (AC_ERROR|DC_ERROR|MV_ERROR)) {
+ s->error_occurred = 1;
+ s->error_count= INT_MAX;
+ }
if(mask == ~0x7F){
memset(&s->error_status_table[start_xy], 0, (end_xy - start_xy) * sizeof(uint8_t));
@@ -1009,7 +1035,12 @@ void ff_er_frame_end(MpegEncContext *s){
int time_pp= s->pp_time;
int time_pb= s->pb_time;
- // FIXME await_progress here
+ if (s->avctx->codec_id == CODEC_ID_H264) {
+ //FIXME
+ } else {
+ ff_thread_await_progress((AVFrame *) s->next_picture_ptr,
+ mb_y, 0);
+ }
s->mv[0][0][0] = s->next_picture.motion_val[0][xy][0]*time_pb/time_pp;
s->mv[0][0][1] = s->next_picture.motion_val[0][xy][1]*time_pb/time_pp;
s->mv[1][0][0] = s->next_picture.motion_val[0][xy][0]*(time_pb - time_pp)/time_pp;
diff --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 2cd96f65d9..f079557759 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -656,8 +656,11 @@ retry:
if(s->slice_height==0 || s->mb_x!=0 || (s->mb_y%s->slice_height)!=0 || get_bits_count(&s->gb) > s->gb.size_in_bits)
break;
}else{
+ int prev_x=s->mb_x, prev_y=s->mb_y;
if(ff_h263_resync(s)<0)
break;
+ if (prev_y * s->mb_width + prev_x < s->mb_y * s->mb_width + s->mb_x)
+ s->error_occurred = 1;
}
if(s->msmpeg4_version<4 && s->h263_pred)
diff --git a/libavcodec/h264.c b/libavcodec/h264.c
index d40ce0d049..dfe9d4a6a5 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -246,6 +246,141 @@ static int ff_h264_decode_rbsp_trailing(H264Context *h, const uint8_t *src){
return 0;
}
+static inline int get_lowest_part_list_y(H264Context *h, Picture *pic, int n, int height,
+ int y_offset, int list){
+ int raw_my= h->mv_cache[list][ scan8[n] ][1];
+ int filter_height= (raw_my&3) ? 2 : 0;
+ int full_my= (raw_my>>2) + y_offset;
+ int top = full_my - filter_height, bottom = full_my + height + filter_height;
+
+ return FFMAX(abs(top), bottom);
+}
+
+static inline void get_lowest_part_y(H264Context *h, int refs[2][48], int n, int height,
+ int y_offset, int list0, int list1, int *nrefs){
+ MpegEncContext * const s = &h->s;
+ int my;
+
+ y_offset += 16*(s->mb_y >> MB_FIELD);
+
+ if(list0){
+ int ref_n = h->ref_cache[0][ scan8[n] ];
+ Picture *ref= &h->ref_list[0][ref_n];
+
+ // Error resilience puts the current picture in the ref list.
+ // Don't try to wait on these as it will cause a deadlock.
+ // Fields can wait on each other, though.
+ if(ref->thread_opaque != s->current_picture.thread_opaque ||
+ (ref->reference&3) != s->picture_structure) {
+ my = get_lowest_part_list_y(h, ref, n, height, y_offset, 0);
+ if (refs[0][ref_n] < 0) nrefs[0] += 1;
+ refs[0][ref_n] = FFMAX(refs[0][ref_n], my);
+ }
+ }
+
+ if(list1){
+ int ref_n = h->ref_cache[1][ scan8[n] ];
+ Picture *ref= &h->ref_list[1][ref_n];
+
+ if(ref->thread_opaque != s->current_picture.thread_opaque ||
+ (ref->reference&3) != s->picture_structure) {
+ my = get_lowest_part_list_y(h, ref, n, height, y_offset, 1);
+ if (refs[1][ref_n] < 0) nrefs[1] += 1;
+ refs[1][ref_n] = FFMAX(refs[1][ref_n], my);
+ }
+ }
+}
+
+/**
+ * Wait until all reference frames are available for MC operations.
+ *
+ * @param h the H264 context
+ */
+static void await_references(H264Context *h){
+ MpegEncContext * const s = &h->s;
+ const int mb_xy= h->mb_xy;
+ const int mb_type= s->current_picture.mb_type[mb_xy];
+ int refs[2][48];
+ int nrefs[2] = {0};
+ int ref, list;
+
+ memset(refs, -1, sizeof(refs));
+
+ if(IS_16X16(mb_type)){
+ get_lowest_part_y(h, refs, 0, 16, 0,
+ IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
+ }else if(IS_16X8(mb_type)){
+ get_lowest_part_y(h, refs, 0, 8, 0,
+ IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
+ get_lowest_part_y(h, refs, 8, 8, 8,
+ IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs);
+ }else if(IS_8X16(mb_type)){
+ get_lowest_part_y(h, refs, 0, 16, 0,
+ IS_DIR(mb_type, 0, 0), IS_DIR(mb_type, 0, 1), nrefs);
+ get_lowest_part_y(h, refs, 4, 16, 0,
+ IS_DIR(mb_type, 1, 0), IS_DIR(mb_type, 1, 1), nrefs);
+ }else{
+ int i;
+
+ assert(IS_8X8(mb_type));
+
+ for(i=0; i<4; i++){
+ const int sub_mb_type= h->sub_mb_type[i];
+ const int n= 4*i;
+ int y_offset= (i&2)<<2;
+
+ if(IS_SUB_8X8(sub_mb_type)){
+ get_lowest_part_y(h, refs, n , 8, y_offset,
+ IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), nrefs);
+ }else if(IS_SUB_8X4(sub_mb_type)){
+ get_lowest_part_y(h, refs, n , 4, y_offset,
+ IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), nrefs);
+ get_lowest_part_y(h, refs, n+2, 4, y_offset+4,
+ IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), nrefs);
+ }else if(IS_SUB_4X8(sub_mb_type)){
+ get_lowest_part_y(h, refs, n , 8, y_offset,
+ IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), nrefs);
+ get_lowest_part_y(h, refs, n+1, 8, y_offset,
+ IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), nrefs);
+ }else{
+ int j;
+ assert(IS_SUB_4X4(sub_mb_type));
+ for(j=0; j<4; j++){
+ int sub_y_offset= y_offset + 2*(j&2);
+ get_lowest_part_y(h, refs, n+j, 4, sub_y_offset,
+ IS_DIR(sub_mb_type, 0, 0), IS_DIR(sub_mb_type, 0, 1), nrefs);
+ }
+ }
+ }
+ }
+
+ for(list=h->list_count-1; list>=0; list--){
+ for(ref=0; ref<48 && nrefs[list]; ref++){
+ int row = refs[list][ref];
+ if(row >= 0){
+ Picture *ref_pic = &h->ref_list[list][ref];
+ int ref_field = ref_pic->reference - 1;
+ int ref_field_picture = ref_pic->field_picture;
+ int pic_height = 16*s->mb_height >> ref_field_picture;
+
+ row <<= MB_MBAFF;
+ nrefs[list]--;
+
+ if(!FIELD_PICTURE && ref_field_picture){ // frame referencing two fields
+ ff_thread_await_progress((AVFrame*)ref_pic, FFMIN((row >> 1) - !(row&1), pic_height-1), 1);
+ ff_thread_await_progress((AVFrame*)ref_pic, FFMIN((row >> 1) , pic_height-1), 0);
+ }else if(FIELD_PICTURE && !ref_field_picture){ // field referencing one field of a frame
+ ff_thread_await_progress((AVFrame*)ref_pic, FFMIN(row*2 + ref_field , pic_height-1), 0);
+ }else if(FIELD_PICTURE){
+ ff_thread_await_progress((AVFrame*)ref_pic, FFMIN(row, pic_height-1), ref_field);
+ }else{
+ ff_thread_await_progress((AVFrame*)ref_pic, FFMIN(row, pic_height-1), 0);
+ }
+ }
+ }
+ }
+}
+
#if 0
/**
* DCT transforms the 16 dc values.
@@ -315,6 +450,7 @@ static void chroma_dc_dct_c(DCTELEM *block){
static void free_tables(H264Context *h, int free_rbsp){
int i;
H264Context *hx;
+
av_freep(&h->intra4x4_pred_mode);
av_freep(&h->chroma_pred_mode_table);
av_freep(&h->cbp_table);
@@ -611,6 +747,7 @@ av_cold int ff_h264_decode_init(AVCodecContext *avctx){
return 0;
}
+
#define IN_RANGE(a, b, size) (((a) >= (b)) && ((a) < ((b)+(size))))
static void copy_picture_range(Picture **to, Picture **from, int count, MpegEncContext *new_base, MpegEncContext *old_base)
{
@@ -711,7 +848,8 @@ static int decode_update_thread_context(AVCodecContext *dst, const AVCodecContex
copy_fields(h, h1, poc_lsb, redundant_pic_count);
//reference lists
- copy_fields(h, h1, ref_count, intra_gb);
+ copy_fields(h, h1, ref_count, list_count);
+ copy_fields(h, h1, ref_list, intra_gb);
copy_fields(h, h1, short_ref, cabac_init_idc);
copy_picture_range(h->short_ref, h1->short_ref, 32, s, s1);
@@ -738,6 +876,7 @@ int ff_h264_frame_start(H264Context *h){
MpegEncContext * const s = &h->s;
int i;
const int pixel_shift = h->pixel_shift;
+ int thread_count = (s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1;
if(MPV_frame_start(s, s->avctx) < 0)
return -1;
@@ -766,7 +905,7 @@ int ff_h264_frame_start(H264Context *h){
/* can't be in alloc_tables because linesize isn't known there.
* FIXME: redo bipred weight to not require extra buffer? */
- for(i = 0; i < s->avctx->thread_count; i++)
+ for(i = 0; i < thread_count; i++)
if(h->thread_context[i] && !h->thread_context[i]->s.obmc_scratchpad)
h->thread_context[i]->s.obmc_scratchpad = av_malloc(16*2*s->linesize + 8*2*s->uvlinesize);
@@ -2910,12 +3049,6 @@ static int decode_nal_units(H264Context *h, const uint8_t *buf, int buf_size){
int nal_index;
h->max_contexts = (HAVE_THREADS && (s->avctx->active_thread_type&FF_THREAD_SLICE)) ? avctx->thread_count : 1;
-#if 0
- int i;
- for(i=0; i<50; i++){
- av_log(NULL, AV_LOG_ERROR,"%02X ", buf[i]);
- }
-#endif
if(!(s->flags2 & CODEC_FLAG2_CHUNKS)){
h->current_slice = 0;
if (!s->first_field)
@@ -3491,8 +3624,7 @@ AVCodec ff_h264_decoder = {
ff_h264_decode_end,
decode_frame,
/*CODEC_CAP_DRAW_HORIZ_BAND |*/ CODEC_CAP_DR1 | CODEC_CAP_DELAY |
- CODEC_CAP_FRAME_THREADS |
- CODEC_CAP_SLICE_THREADS,
+ CODEC_CAP_SLICE_THREADS | CODEC_CAP_FRAME_THREADS,
.flush= flush_dpb,
.long_name = NULL_IF_CONFIG_SMALL("H.264 / AVC / MPEG-4 AVC / MPEG-4 part 10"),
.init_thread_copy = ONLY_IF_THREADS_ENABLED(decode_init_thread_copy),
diff --git a/libavcodec/indeo5.c b/libavcodec/indeo5.c
index 5135c46bc7..4c6bfd66d1 100644
--- a/libavcodec/indeo5.c
+++ b/libavcodec/indeo5.c
@@ -629,7 +629,7 @@ static int decode_band(IVI5DecContext *ctx, int plane_num,
FFSWAP(int16_t, band->rv_map->valtab[idx1], band->rv_map->valtab[idx2]);
}
-#if IVI_DEBUG
+#ifdef DEBUG
if (band->checksum_present) {
uint16_t chksum = ivi_calc_band_checksum(band);
if (chksum != band->checksum) {
diff --git a/libavcodec/interplayvideo.c b/libavcodec/interplayvideo.c
index d539cfc207..7e26e1db7d 100644
--- a/libavcodec/interplayvideo.c
+++ b/libavcodec/interplayvideo.c
@@ -46,14 +46,6 @@
#define PALETTE_COUNT 256
-/* debugging support */
-#define DEBUG_INTERPLAY 0
-#if DEBUG_INTERPLAY
-#define debug_interplay(x,...) av_log(NULL, AV_LOG_DEBUG, x, __VA_ARGS__)
-#else
-static inline void debug_interplay(const char *format, ...) { }
-#endif
-
typedef struct IpvideoContext {
AVCodecContext *avctx;
@@ -141,7 +133,7 @@ static int ipvideo_decode_block_opcode_0x2(IpvideoContext *s)
y = 8 + ((B - 56) / 29);
}
- debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
+ av_dlog(NULL, " motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
return copy_from(s, &s->second_last_frame, x, y);
}
@@ -169,7 +161,7 @@ static int ipvideo_decode_block_opcode_0x3(IpvideoContext *s)
y = -( 8 + ((B - 56) / 29));
}
- debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
+ av_dlog(NULL, " motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
return copy_from(s, &s->current_frame, x, y);
}
@@ -192,7 +184,7 @@ static int ipvideo_decode_block_opcode_0x4(IpvideoContext *s)
x = -8 + BL;
y = -8 + BH;
- debug_interplay (" motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
+ av_dlog(NULL, " motion byte = %d, (x, y) = (%d, %d)\n", B, x, y);
return copy_from(s, &s->last_frame, x, y);
}
@@ -207,7 +199,7 @@ static int ipvideo_decode_block_opcode_0x5(IpvideoContext *s)
x = *s->stream_ptr++;
y = *s->stream_ptr++;
- debug_interplay (" motion bytes = %d, %d\n", x, y);
+ av_dlog(NULL, " motion bytes = %d, %d\n", x, y);
return copy_from(s, &s->last_frame, x, y);
}
@@ -588,7 +580,7 @@ static int ipvideo_decode_block_opcode_0x6_16(IpvideoContext *s)
x = *s->stream_ptr++;
y = *s->stream_ptr++;
- debug_interplay (" motion bytes = %d, %d\n", x, y);
+ av_dlog(NULL, " motion bytes = %d, %d\n", x, y);
return copy_from(s, &s->second_last_frame, x, y);
}
@@ -965,7 +957,7 @@ static void ipvideo_decode_opcodes(IpvideoContext *s)
static int frame = 0;
GetBitContext gb;
- debug_interplay("------------------ frame %d\n", frame);
+ av_dlog(NULL, "------------------ frame %d\n", frame);
frame++;
if (!s->is_16bpp) {
@@ -991,8 +983,8 @@ static void ipvideo_decode_opcodes(IpvideoContext *s)
for (x = 0; x < s->avctx->width; x += 8) {
opcode = get_bits(&gb, 4);
- debug_interplay(" block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n",
- x, y, opcode, s->stream_ptr);
+ av_dlog(NULL, " block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n",
+ x, y, opcode, s->stream_ptr);
if (!s->is_16bpp) {
s->pixel_ptr = s->current_frame.data[0] + x
diff --git a/libavcodec/ituh263dec.c b/libavcodec/ituh263dec.c
index e0d57a763d..b1e67231fd 100644
--- a/libavcodec/ituh263dec.c
+++ b/libavcodec/ituh263dec.c
@@ -152,7 +152,7 @@ int ff_h263_decode_mba(MpegEncContext *s)
*/
static int h263_decode_gob_header(MpegEncContext *s)
{
- unsigned int val, gfid, gob_number;
+ unsigned int val, gob_number;
int left;
/* Check for GOB Start Code */
@@ -183,12 +183,12 @@ static int h263_decode_gob_header(MpegEncContext *s)
s->qscale = get_bits(&s->gb, 5); /* SQUANT */
if(get_bits1(&s->gb)==0)
return -1;
- gfid = get_bits(&s->gb, 2); /* GFID */
+ skip_bits(&s->gb, 2); /* GFID */
}else{
gob_number = get_bits(&s->gb, 5); /* GN */
s->mb_x= 0;
s->mb_y= s->gob_index* gob_number;
- gfid = get_bits(&s->gb, 2); /* GFID */
+ skip_bits(&s->gb, 2); /* GFID */
s->qscale = get_bits(&s->gb, 5); /* GQUANT */
}
diff --git a/libavcodec/ivi_common.c b/libavcodec/ivi_common.c
index 0e552bccfe..7f14a89f33 100644
--- a/libavcodec/ivi_common.c
+++ b/libavcodec/ivi_common.c
@@ -418,8 +418,8 @@ int ff_ivi_decode_blocks(GetBitContext *gb, IVIBandDesc *band, IVITile *tile)
break;
pos = band->scan[scan_pos];
- if (IVI_DEBUG && !val)
- av_log(NULL, AV_LOG_ERROR, "Val = 0 encountered!\n");
+ if (!val)
+ av_dlog(NULL, "Val = 0 encountered!\n");
q = (base_tab[pos] * quant) >> 9;
if (q > 1)
@@ -563,7 +563,7 @@ void ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
}
-#if IVI_DEBUG
+#ifdef DEBUG
uint16_t ivi_calc_band_checksum (IVIBandDesc *band)
{
int x, y;
diff --git a/libavcodec/ivi_common.h b/libavcodec/ivi_common.h
index 803c0580be..10cca26045 100644
--- a/libavcodec/ivi_common.h
+++ b/libavcodec/ivi_common.h
@@ -33,8 +33,6 @@
#include "get_bits.h"
#include <stdint.h>
-#define IVI_DEBUG 0
-
#define IVI_VLC_BITS 13 ///< max number of bits of the ivi's huffman codes
/**
@@ -340,7 +338,6 @@ void ff_ivi_process_empty_tile(AVCodecContext *avctx, IVIBandDesc *band,
*/
void ff_ivi_output_plane(IVIPlaneDesc *plane, uint8_t *dst, int dst_pitch);
-#if IVI_DEBUG
/**
* Calculate band checksum from band data.
*/
@@ -350,6 +347,5 @@ uint16_t ivi_calc_band_checksum (IVIBandDesc *band);
* Verify that band data lies in range.
*/
int ivi_check_band (IVIBandDesc *band, const uint8_t *ref, int pitch);
-#endif
#endif /* AVCODEC_IVI_COMMON_H */
diff --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index 6227efd51f..ca2c8f452d 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -1670,7 +1670,7 @@ static int mpeg_field_start(MpegEncContext *s, const uint8_t *buf, int buf_size)
*s->current_picture_ptr->pan_scan= s1->pan_scan;
- if (HAVE_PTHREADS && avctx->active_thread_type&FF_THREAD_FRAME)
+ if (HAVE_PTHREADS && (avctx->active_thread_type & FF_THREAD_FRAME))
ff_thread_finish_setup(avctx);
}else{ //second field
int i;
@@ -2004,7 +2004,7 @@ static int slice_end(AVCodecContext *avctx, AVFrame *pict)
*pict= *(AVFrame*)s->current_picture_ptr;
ff_print_debug_info(s, pict);
} else {
- if (avctx->active_thread_type&FF_THREAD_FRAME)
+ if (avctx->active_thread_type & FF_THREAD_FRAME)
s->picture_number++;
/* latency of 1 frame for I- and P-frames */
/* XXX: use another variable than picture_number */
@@ -2179,14 +2179,13 @@ static void mpeg_decode_gop(AVCodecContext *avctx,
Mpeg1Context *s1 = avctx->priv_data;
MpegEncContext *s = &s1->mpeg_enc_ctx;
- int drop_frame_flag;
int time_code_hours, time_code_minutes;
int time_code_seconds, time_code_pictures;
int broken_link;
init_get_bits(&s->gb, buf, buf_size*8);
- drop_frame_flag = get_bits1(&s->gb);
+ skip_bits1(&s->gb); /* drop_frame_flag */
time_code_hours=get_bits(&s->gb,5);
time_code_minutes = get_bits(&s->gb,6);
@@ -2340,7 +2339,7 @@ static int decode_chunks(AVCodecContext *avctx,
buf_ptr = ff_find_start_code(buf_ptr,buf_end, &start_code);
if (start_code > 0x1ff){
if(s2->pict_type != AV_PICTURE_TYPE_B || avctx->skip_frame <= AVDISCARD_DEFAULT){
- if(HAVE_THREADS && avctx->active_thread_type&FF_THREAD_SLICE){
+ if(HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)){
int i;
assert(avctx->thread_count > 1);
@@ -2509,7 +2508,7 @@ static int decode_chunks(AVCodecContext *avctx,
break;
}
- if(HAVE_THREADS && avctx->active_thread_type&FF_THREAD_SLICE){
+ if(HAVE_THREADS && (avctx->active_thread_type & FF_THREAD_SLICE)){
int threshold= (s2->mb_height*s->slice_count + avctx->thread_count/2) / avctx->thread_count;
assert(avctx->thread_count > 1);
if(threshold <= mb_y){
diff --git a/libavcodec/mpeg12enc.c b/libavcodec/mpeg12enc.c
index 487551171c..41344562b2 100644
--- a/libavcodec/mpeg12enc.c
+++ b/libavcodec/mpeg12enc.c
@@ -761,10 +761,9 @@ void ff_mpeg1_encode_init(MpegEncContext *s)
if(mv==0) len= ff_mpeg12_mbMotionVectorTable[0][1];
else{
- int val, bit_size, range, code;
+ int val, bit_size, code;
bit_size = f_code - 1;
- range = 1 << bit_size;
val=mv;
if (val < 0)
diff --git a/libavcodec/mpeg4videodec.c b/libavcodec/mpeg4videodec.c
index a9d67f220c..6b7b4bfbc0 100644
--- a/libavcodec/mpeg4videodec.c
+++ b/libavcodec/mpeg4videodec.c
@@ -397,14 +397,13 @@ int mpeg4_decode_video_packet_header(MpegEncContext *s)
header_extension= get_bits1(&s->gb);
}
if(header_extension){
- int time_increment;
int time_incr=0;
while (get_bits1(&s->gb) != 0)
time_incr++;
check_marker(&s->gb, "before time_increment in video packed header");
- time_increment= get_bits(&s->gb, s->time_increment_bits);
+ skip_bits(&s->gb, s->time_increment_bits); /* time_increment */
check_marker(&s->gb, "before vop_coding_type in video packed header");
skip_bits(&s->gb, 2); /* vop coding type */
@@ -1805,16 +1804,14 @@ no_cplx_est:
if (s->scalability) {
GetBitContext bak= *gb;
- int ref_layer_id;
- int ref_layer_sampling_dir;
int h_sampling_factor_n;
int h_sampling_factor_m;
int v_sampling_factor_n;
int v_sampling_factor_m;
s->hierachy_type= get_bits1(gb);
- ref_layer_id= get_bits(gb, 4);
- ref_layer_sampling_dir= get_bits1(gb);
+ skip_bits(gb, 4); /* ref_layer_id */
+ skip_bits1(gb); /* ref_layer_sampling_dir */
h_sampling_factor_n= get_bits(gb, 5);
h_sampling_factor_m= get_bits(gb, 5);
v_sampling_factor_n= get_bits(gb, 5);
@@ -1993,15 +1990,13 @@ static int decode_vop_header(MpegEncContext *s, GetBitContext *gb){
if (s->shape != RECT_SHAPE) {
if (s->vol_sprite_usage != 1 || s->pict_type != AV_PICTURE_TYPE_I) {
- int width, height, hor_spat_ref, ver_spat_ref;
-
- width = get_bits(gb, 13);
+ skip_bits(gb, 13); /* width */
skip_bits1(gb); /* marker */
- height = get_bits(gb, 13);
+ skip_bits(gb, 13); /* height */
skip_bits1(gb); /* marker */
- hor_spat_ref = get_bits(gb, 13); /* hor_spat_ref */
+ skip_bits(gb, 13); /* hor_spat_ref */
skip_bits1(gb); /* marker */
- ver_spat_ref = get_bits(gb, 13); /* ver_spat_ref */
+ skip_bits(gb, 13); /* ver_spat_ref */
}
skip_bits1(gb); /* change_CR_disable */
diff --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 80c6bb386a..edc9e229fa 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -527,7 +527,7 @@ int ff_mpeg_update_thread_context(AVCodecContext *dst, const AVCodecContext *src
s->last_pict_type= s1->pict_type;
if (s1->current_picture_ptr) s->last_lambda_for[s1->pict_type] = s1->current_picture_ptr->quality;
- if(s1->pict_type!=AV_PICTURE_TYPE_B){
+ if(s1->pict_type!=FF_B_TYPE){
s->last_non_b_pict_type= s1->pict_type;
}
}
@@ -586,7 +586,8 @@ av_cold int MPV_common_init(MpegEncContext *s)
return -1;
}
- if(s->avctx->active_thread_type&FF_THREAD_SLICE &&
+
+ if((s->avctx->active_thread_type & FF_THREAD_SLICE) &&
(s->avctx->thread_count > MAX_THREADS || (s->avctx->thread_count > s->mb_height && s->mb_height))){
av_log(s->avctx, AV_LOG_ERROR, "too many threads\n");
return -1;
@@ -763,6 +764,7 @@ av_cold int MPV_common_init(MpegEncContext *s)
if(init_duplicate_context(s, s) < 0) goto fail;
s->start_mb_y = 0;
s->end_mb_y = s->mb_height;
+
}
return 0;
@@ -2634,6 +2636,6 @@ void ff_set_qscale(MpegEncContext * s, int qscale)
void MPV_report_decode_progress(MpegEncContext *s)
{
- if (s->pict_type != AV_PICTURE_TYPE_B && !s->partitioned_frame)
+ if (s->pict_type != FF_B_TYPE && !s->partitioned_frame && !s->error_occurred)
ff_thread_report_progress((AVFrame*)s->current_picture_ptr, s->mb_y, 0);
}
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index bb403c7de6..ec9a04a7ae 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -474,7 +474,7 @@ typedef struct MpegEncContext {
int last_bits; ///< temp var used for calculating the above vars
/* error concealment / resync */
- int error_count;
+ int error_count, error_occurred;
uint8_t *error_status_table; ///< table of the error status of each MB
#define VP_START 1 ///< current MB is the first after a resync marker
#define AC_ERROR 2
diff --git a/libavcodec/mpegvideo_enc.c b/libavcodec/mpegvideo_enc.c
index c5a58c2ecc..4f5b56dd8f 100644
--- a/libavcodec/mpegvideo_enc.c
+++ b/libavcodec/mpegvideo_enc.c
@@ -2759,7 +2759,7 @@ static int encode_picture(MpegEncContext *s, int picture_number)
{
int i;
int bits;
- int context_count = s->avctx->active_thread_type&FF_THREAD_SLICE ? s->avctx->thread_count : 1;
+ int context_count = (s->avctx->active_thread_type & FF_THREAD_SLICE) ? s->avctx->thread_count : 1;
s->picture_number = picture_number;
diff --git a/libavcodec/mpegvideo_parser.c b/libavcodec/mpegvideo_parser.c
index 6369224d1a..cfc950d017 100644
--- a/libavcodec/mpegvideo_parser.c
+++ b/libavcodec/mpegvideo_parser.c
@@ -32,7 +32,7 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
uint32_t start_code;
int frame_rate_index, ext_type, bytes_left;
int frame_rate_ext_n, frame_rate_ext_d;
- int picture_structure, top_field_first, repeat_first_field, progressive_frame;
+ int top_field_first, repeat_first_field, progressive_frame;
int horiz_size_ext, vert_size_ext, bit_rate_ext;
int did_set_size=0;
//FIXME replace the crap with get_bits()
@@ -91,7 +91,6 @@ static void mpegvideo_extract_headers(AVCodecParserContext *s,
break;
case 0x8: /* picture coding extension */
if (bytes_left >= 5) {
- picture_structure = buf[2]&3;
top_field_first = buf[3] & (1 << 7);
repeat_first_field = buf[3] & (1 << 1);
progressive_frame = buf[4] & (1 << 7);
diff --git a/libavcodec/msmpeg4.c b/libavcodec/msmpeg4.c
index 8eb0418821..06098b04a1 100644
--- a/libavcodec/msmpeg4.c
+++ b/libavcodec/msmpeg4.c
@@ -1528,9 +1528,7 @@ int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size)
/* the alt_bitstream reader could read over the end so we need to check it */
if(left>=length && left<length+8)
{
- int fps;
-
- fps= get_bits(&s->gb, 5);
+ skip_bits(&s->gb, 5); /* fps */
s->bit_rate= get_bits(&s->gb, 11)*1024;
if(s->msmpeg4_version>=3)
s->flipflop_rounding= get_bits1(&s->gb);
diff --git a/libavcodec/pngdec.c b/libavcodec/pngdec.c
index 9732396dc6..05ba027802 100644
--- a/libavcodec/pngdec.c
+++ b/libavcodec/pngdec.c
@@ -379,7 +379,7 @@ static int decode_frame(AVCodecContext *avctx,
AVFrame *p;
uint8_t *crow_buf_base = NULL;
uint32_t tag, length;
- int ret, crc;
+ int ret;
FFSWAP(AVFrame *, s->current_picture, s->last_picture);
avctx->coded_frame= s->current_picture;
@@ -433,7 +433,7 @@ static int decode_frame(AVCodecContext *avctx,
s->compression_type = *s->bytestream++;
s->filter_type = *s->bytestream++;
s->interlace_type = *s->bytestream++;
- crc = bytestream_get_be32(&s->bytestream);
+ s->bytestream += 4; /* crc */
s->state |= PNG_IHDR;
av_dlog(avctx, "width=%d height=%d depth=%d color_type=%d compression_type=%d filter_type=%d interlace_type=%d\n",
s->width, s->height, s->bit_depth, s->color_type,
@@ -528,8 +528,7 @@ static int decode_frame(AVCodecContext *avctx,
s->state |= PNG_IDAT;
if (png_decode_idat(s, length) < 0)
goto fail;
- /* skip crc */
- crc = bytestream_get_be32(&s->bytestream);
+ s->bytestream += 4; /* crc */
break;
case MKTAG('P', 'L', 'T', 'E'):
{
@@ -549,7 +548,7 @@ static int decode_frame(AVCodecContext *avctx,
s->palette[i] = (0xff << 24);
}
s->state |= PNG_PLTE;
- crc = bytestream_get_be32(&s->bytestream);
+ s->bytestream += 4; /* crc */
}
break;
case MKTAG('t', 'R', 'N', 'S'):
@@ -565,13 +564,13 @@ static int decode_frame(AVCodecContext *avctx,
v = *s->bytestream++;
s->palette[i] = (s->palette[i] & 0x00ffffff) | (v << 24);
}
- crc = bytestream_get_be32(&s->bytestream);
+ s->bytestream += 4; /* crc */
}
break;
case MKTAG('I', 'E', 'N', 'D'):
if (!(s->state & PNG_ALLIMAGE))
goto fail;
- crc = bytestream_get_be32(&s->bytestream);
+ s->bytestream += 4; /* crc */
goto exit_loop;
default:
/* skip tag */
diff --git a/libavcodec/pthread.c b/libavcodec/pthread.c
index 4b68bce371..e662fb9caf 100644
--- a/libavcodec/pthread.c
+++ b/libavcodec/pthread.c
@@ -55,7 +55,7 @@ typedef struct ThreadContext {
} ThreadContext;
/// Max number of frame buffers that can be allocated when using frame threads.
-#define MAX_BUFFERS 33
+#define MAX_BUFFERS (32+1)
/**
* Context used by codec threads and stored in their AVCodecContext thread_opaque.
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 2ce7ea00b6..2f822a8ac2 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -235,7 +235,7 @@ int rv_decode_dc(MpegEncContext *s, int n)
/* read RV 1.0 compatible frame header */
static int rv10_decode_picture_header(MpegEncContext *s)
{
- int mb_count, pb_frame, marker, unk av_unused, mb_xy;
+ int mb_count, pb_frame, marker, mb_xy;
marker = get_bits1(&s->gb);
@@ -282,7 +282,7 @@ static int rv10_decode_picture_header(MpegEncContext *s)
s->mb_y = 0;
mb_count = s->mb_width * s->mb_height;
}
- unk= get_bits(&s->gb, 3); /* ignored */
+ skip_bits(&s->gb, 3); /* ignored */
s->f_code = 1;
s->unrestricted_mv = 1;
diff --git a/libavcodec/s302m.c b/libavcodec/s302m.c
index d707208b6c..e49827ba7b 100644
--- a/libavcodec/s302m.c
+++ b/libavcodec/s302m.c
@@ -29,7 +29,7 @@ static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf,
int buf_size)
{
uint32_t h;
- int frame_size, channels, id av_unused, bits;
+ int frame_size, channels, bits;
if (buf_size <= AES3_HEADER_LEN) {
av_log(avctx, AV_LOG_ERROR, "frame is too short\n");
@@ -48,7 +48,6 @@ static int s302m_parse_frame_header(AVCodecContext *avctx, const uint8_t *buf,
h = AV_RB32(buf);
frame_size = (h >> 16) & 0xffff;
channels = ((h >> 14) & 0x0003) * 2 + 2;
- id = (h >> 6) & 0x00ff;
bits = ((h >> 4) & 0x0003) * 4 + 16;
if (AES3_HEADER_LEN + frame_size != buf_size || bits > 24) {
diff --git a/libavcodec/shorten.c b/libavcodec/shorten.c
index b2a05cc259..734ea63785 100644
--- a/libavcodec/shorten.c
+++ b/libavcodec/shorten.c
@@ -196,7 +196,6 @@ static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header
{
GetBitContext hb;
int len;
- int chunk_size av_unused;
short wave_format;
init_get_bits(&hb, header, header_size*8);
@@ -205,7 +204,7 @@ static int decode_wave_header(AVCodecContext *avctx, uint8_t *header, int header
return -1;
}
- chunk_size = get_le32(&hb);
+ skip_bits_long(&hb, 32); /* chunk_size */
if (get_le32(&hb) != MKTAG('W','A','V','E')) {
av_log(avctx, AV_LOG_ERROR, "missing WAVE tag\n");
diff --git a/libavcodec/svq1dec.c b/libavcodec/svq1dec.c
index eff1454241..f2690fbf33 100644
--- a/libavcodec/svq1dec.c
+++ b/libavcodec/svq1dec.c
@@ -33,7 +33,6 @@
*/
-//#define DEBUG_SVQ1
#include "avcodec.h"
#include "dsputil.h"
#include "mpegvideo.h"
@@ -238,9 +237,9 @@ static int svq1_decode_block_intra (GetBitContext *bitbuf, uint8_t *pixels, int
}
if ((stages > 0) && (level >= 4)) {
-#ifdef DEBUG_SVQ1
- av_log(s->avctx, AV_LOG_INFO, "Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",stages,level);
-#endif
+ av_dlog(NULL,
+ "Error (svq1_decode_block_intra): invalid vector: stages=%i level=%i\n",
+ stages, level);
return -1; /* invalid vector */
}
@@ -288,9 +287,9 @@ static int svq1_decode_block_non_intra (GetBitContext *bitbuf, uint8_t *pixels,
if (stages == -1) continue; /* skip vector */
if ((stages > 0) && (level >= 4)) {
-#ifdef DEBUG_SVQ1
- av_log(s->avctx, AV_LOG_INFO, "Error (svq1_decode_block_non_intra): invalid vector: stages=%i level=%i\n",stages,level);
-#endif
+ av_dlog(NULL,
+ "Error (svq1_decode_block_non_intra): invalid vector: stages=%i level=%i\n",
+ stages, level);
return -1; /* invalid vector */
}
@@ -499,9 +498,7 @@ static int svq1_decode_delta_block (MpegEncContext *s, GetBitContext *bitbuf,
if (result != 0)
{
-#ifdef DEBUG_SVQ1
- av_log(s->avctx, AV_LOG_INFO, "Error in svq1_motion_inter_block %i\n",result);
-#endif
+ av_dlog(s->avctx, "Error in svq1_motion_inter_block %i\n", result);
break;
}
result = svq1_decode_block_non_intra (bitbuf, current, pitch);
@@ -512,9 +509,7 @@ static int svq1_decode_delta_block (MpegEncContext *s, GetBitContext *bitbuf,
if (result != 0)
{
-#ifdef DEBUG_SVQ1
- av_log(s->avctx, AV_LOG_INFO, "Error in svq1_motion_inter_4v_block %i\n",result);
-#endif
+ av_dlog(s->avctx, "Error in svq1_motion_inter_4v_block %i\n", result);
break;
}
result = svq1_decode_block_non_intra (bitbuf, current, pitch);
@@ -554,9 +549,8 @@ static void svq1_parse_string (GetBitContext *bitbuf, uint8_t *out) {
static int svq1_decode_frame_header (GetBitContext *bitbuf,MpegEncContext *s) {
int frame_size_code;
- int temporal_reference;
- temporal_reference = get_bits (bitbuf, 8);
+ skip_bits(bitbuf, 8); /* temporal_reference */
/* frame type */
s->pict_type= get_bits (bitbuf, 2)+1;
@@ -661,9 +655,7 @@ static int svq1_decode_frame(AVCodecContext *avctx,
if (result != 0)
{
-#ifdef DEBUG_SVQ1
- av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_frame_header %i\n",result);
-#endif
+ av_dlog(s->avctx, "Error in svq1_decode_frame_header %i\n",result);
return result;
}
@@ -712,9 +704,7 @@ static int svq1_decode_frame(AVCodecContext *avctx,
result = svq1_decode_block_intra (&s->gb, &current[x], linesize);
if (result != 0)
{
-//#ifdef DEBUG_SVQ1
av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_block %i (keyframe)\n",result);
-//#endif
goto err;
}
}
@@ -730,9 +720,7 @@ static int svq1_decode_frame(AVCodecContext *avctx,
linesize, pmv, x, y);
if (result != 0)
{
-#ifdef DEBUG_SVQ1
- av_log(s->avctx, AV_LOG_INFO, "Error in svq1_decode_delta_block %i\n",result);
-#endif
+ av_dlog(s->avctx, "Error in svq1_decode_delta_block %i\n",result);
goto err;
}
}
diff --git a/libavcodec/targa.c b/libavcodec/targa.c
index 07173c7bc5..41741ff9c5 100644
--- a/libavcodec/targa.c
+++ b/libavcodec/targa.c
@@ -108,18 +108,18 @@ static int decode_frame(AVCodecContext *avctx,
AVFrame * const p= (AVFrame*)&s->picture;
uint8_t *dst;
int stride;
- int idlen, pal, compr, x, y, w, h, bpp, flags;
+ int idlen, compr, y, w, h, bpp, flags;
int first_clr, colors, csize;
/* parse image header */
CHECK_BUFFER_SIZE(buf, buf_end, 18, "header");
idlen = *buf++;
- pal = *buf++;
+ buf++; /* pal */
compr = *buf++;
first_clr = AV_RL16(buf); buf += 2;
colors = AV_RL16(buf); buf += 2;
csize = *buf++;
- x = AV_RL16(buf); buf += 2;
+ buf += 2; /* x */
y = AV_RL16(buf); buf += 2;
w = AV_RL16(buf); buf += 2;
h = AV_RL16(buf); buf += 2;
@@ -210,6 +210,7 @@ static int decode_frame(AVCodecContext *avctx,
CHECK_BUFFER_SIZE(buf, buf_end, img_size, "image data");
for(y = 0; y < s->height; y++){
#if HAVE_BIGENDIAN
+ int x;
if((s->bpp + 1) >> 3 == 2){
uint16_t *dst16 = (uint16_t*)dst;
for(x = 0; x < s->width; x++)
diff --git a/libavcodec/truemotion2.c b/libavcodec/truemotion2.c
index f09a5edd99..2b9a0cba72 100644
--- a/libavcodec/truemotion2.c
+++ b/libavcodec/truemotion2.c
@@ -211,19 +211,6 @@ static inline int tm2_read_header(TM2Context *ctx, const uint8_t *buf)
/* av_log (ctx->avctx, AV_LOG_ERROR, "TM2 old header: not implemented (yet)\n"); */
return 40;
} else if(magic == 0x00000101) { /* new header */
- av_unused int w, h, size, flags, xr, yr, length;
-
- length = AV_RL32(buf);
- buf += 4;
-
- init_get_bits(&ctx->gb, buf, 32 * 8);
- size = get_bits_long(&ctx->gb, 31);
- h = get_bits(&ctx->gb, 15);
- w = get_bits(&ctx->gb, 15);
- flags = get_bits_long(&ctx->gb, 31);
- yr = get_bits(&ctx->gb, 9);
- xr = get_bits(&ctx->gb, 9);
-
return 40;
} else {
av_log (ctx->avctx, AV_LOG_ERROR, "Not a TM2 header: 0x%08X\n", magic);
diff --git a/libavcodec/tscc.c b/libavcodec/tscc.c
index e12b9a31fc..bc57ec74cb 100644
--- a/libavcodec/tscc.c
+++ b/libavcodec/tscc.c
@@ -75,7 +75,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
int buf_size = avpkt->size;
CamtasiaContext * const c = avctx->priv_data;
const unsigned char *encoded = buf;
- unsigned char *outptr;
int zret; // Zlib return code
int len = buf_size;
@@ -89,8 +88,6 @@ static int decode_frame(AVCodecContext *avctx, void *data, int *data_size, AVPac
return -1;
}
- outptr = c->pic.data[0]; // Output image pointer
-
zret = inflateReset(&(c->zstream));
if (zret != Z_OK) {
av_log(avctx, AV_LOG_ERROR, "Inflate reset error: %d\n", zret);
diff --git a/libavcodec/utils.c b/libavcodec/utils.c
index 1c61e68910..cb94b1036f 100644
--- a/libavcodec/utils.c
+++ b/libavcodec/utils.c
@@ -115,7 +115,7 @@ typedef struct InternalBuffer{
enum PixelFormat pix_fmt;
}InternalBuffer;
-#define INTERNAL_BUFFER_SIZE 33
+#define INTERNAL_BUFFER_SIZE (32+1)
void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height, int linesize_align[4]){
int w_align= 1;
diff --git a/libavcodec/vorbis.c b/libavcodec/vorbis.c
index a805452eab..fc830293cc 100644
--- a/libavcodec/vorbis.c
+++ b/libavcodec/vorbis.c
@@ -20,9 +20,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#undef V_DEBUG
-//#define V_DEBUG
-
#define ALT_BITSTREAM_READER_LE
#include "avcodec.h"
#include "get_bits.h"
@@ -57,7 +54,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
unsigned i, j, p, code;
-#ifdef V_DEBUG
+#ifdef DEBUG
GetBitContext gb;
#endif
@@ -74,7 +71,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
for (i = 0; i < bits[p]; ++i)
exit_at_level[i+1] = 1 << i;
-#ifdef V_DEBUG
+#ifdef DEBUG
av_log(NULL, AV_LOG_INFO, " %u. of %u code len %d code %d - ", p, num, bits[p], codes[p]);
init_get_bits(&gb, (uint8_t *)&codes[p], bits[p]);
for (i = 0; i < bits[p]; ++i)
@@ -102,7 +99,7 @@ int ff_vorbis_len2vlc(uint8_t *bits, uint32_t *codes, unsigned num)
exit_at_level[j] = code + (1 << (j - 1));
codes[p] = code;
-#ifdef V_DEBUG
+#ifdef DEBUG
av_log(NULL, AV_LOG_INFO, " %d. code len %d code %d - ", p, bits[p], codes[p]);
init_get_bits(&gb, (uint8_t *)&codes[p], bits[p]);
for (i = 0; i < bits[p]; ++i)
diff --git a/libavcodec/vorbisdec.c b/libavcodec/vorbisdec.c
index f93fff113f..73a9b41145 100644
--- a/libavcodec/vorbisdec.c
+++ b/libavcodec/vorbisdec.c
@@ -20,10 +20,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
-#undef V_DEBUG
-//#define V_DEBUG
-//#define AV_DEBUG(...) av_log(NULL, AV_LOG_INFO, __VA_ARGS__)
-
#include <math.h>
#define ALT_BITSTREAM_READER_LE
@@ -41,10 +37,6 @@
#define V_MAX_VLCS (1 << 16)
#define V_MAX_PARTITIONS (1 << 20)
-#ifndef V_DEBUG
-#define AV_DEBUG(...)
-#endif
-
#undef NDEBUG
#include <assert.h>
@@ -245,7 +237,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
vc->codebook_count = get_bits(gb, 8) + 1;
- AV_DEBUG(" Codebooks: %d \n", vc->codebook_count);
+ av_dlog(NULL, " Codebooks: %d \n", vc->codebook_count);
vc->codebooks = av_mallocz(vc->codebook_count * sizeof(*vc->codebooks));
tmp_vlc_bits = av_mallocz(V_MAX_VLCS * sizeof(*tmp_vlc_bits));
@@ -256,7 +248,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
vorbis_codebook *codebook_setup = &vc->codebooks[cb];
unsigned ordered, t, entries, used_entries = 0;
- AV_DEBUG(" %u. Codebook\n", cb);
+ av_dlog(NULL, " %u. Codebook\n", cb);
if (get_bits(gb, 24) != 0x564342) {
av_log(vc->avccontext, AV_LOG_ERROR,
@@ -281,17 +273,17 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
ordered = get_bits1(gb);
- AV_DEBUG(" codebook_dimensions %d, codebook_entries %u\n",
- codebook_setup->dimensions, entries);
+ av_dlog(NULL, " codebook_dimensions %d, codebook_entries %u\n",
+ codebook_setup->dimensions, entries);
if (!ordered) {
unsigned ce, flag;
unsigned sparse = get_bits1(gb);
- AV_DEBUG(" not ordered \n");
+ av_dlog(NULL, " not ordered \n");
if (sparse) {
- AV_DEBUG(" sparse \n");
+ av_dlog(NULL, " sparse \n");
used_entries = 0;
for (ce = 0; ce < entries; ++ce) {
@@ -303,7 +295,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
tmp_vlc_bits[ce] = 0;
}
} else {
- AV_DEBUG(" not sparse \n");
+ av_dlog(NULL, " not sparse \n");
used_entries = entries;
for (ce = 0; ce < entries; ++ce)
@@ -313,17 +305,17 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
unsigned current_entry = 0;
unsigned current_length = get_bits(gb, 5) + 1;
- AV_DEBUG(" ordered, current length: %u\n", current_length); //FIXME
+ av_dlog(NULL, " ordered, current length: %u\n", current_length); //FIXME
used_entries = entries;
for (; current_entry < used_entries && current_length <= 32; ++current_length) {
unsigned i, number;
- AV_DEBUG(" number bits: %u ", ilog(entries - current_entry));
+ av_dlog(NULL, " number bits: %u ", ilog(entries - current_entry));
number = get_bits(gb, ilog(entries - current_entry));
- AV_DEBUG(" number: %u\n", number);
+ av_dlog(NULL, " number: %u\n", number);
for (i = current_entry; i < number+current_entry; ++i)
if (i < used_entries)
@@ -339,7 +331,8 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
codebook_setup->lookup_type = get_bits(gb, 4);
- AV_DEBUG(" lookup type: %d : %s \n", codebook_setup->lookup_type, codebook_setup->lookup_type ? "vq" : "no lookup");
+ av_dlog(NULL, " lookup type: %d : %s \n", codebook_setup->lookup_type,
+ codebook_setup->lookup_type ? "vq" : "no lookup");
// If the codebook is used for (inverse) VQ, calculate codevectors.
@@ -352,14 +345,17 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
unsigned codebook_value_bits = get_bits(gb, 4) + 1;
unsigned codebook_sequence_p = get_bits1(gb);
- AV_DEBUG(" We expect %d numbers for building the codevectors. \n", codebook_lookup_values);
- AV_DEBUG(" delta %f minmum %f \n", codebook_delta_value, codebook_minimum_value);
+ av_dlog(NULL, " We expect %d numbers for building the codevectors. \n",
+ codebook_lookup_values);
+ av_dlog(NULL, " delta %f minmum %f \n",
+ codebook_delta_value, codebook_minimum_value);
for (i = 0; i < codebook_lookup_values; ++i) {
codebook_multiplicands[i] = get_bits(gb, codebook_value_bits);
- AV_DEBUG(" multiplicands*delta+minmum : %e \n", (float)codebook_multiplicands[i]*codebook_delta_value+codebook_minimum_value);
- AV_DEBUG(" multiplicand %u\n", codebook_multiplicands[i]);
+ av_dlog(NULL, " multiplicands*delta+minmum : %e \n",
+ (float)codebook_multiplicands[i] * codebook_delta_value + codebook_minimum_value);
+ av_dlog(NULL, " multiplicand %u\n", codebook_multiplicands[i]);
}
// Weed out unused vlcs and build codevector vector
@@ -374,9 +370,7 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
float last = 0.0;
unsigned lookup_offset = i;
-#ifdef V_DEBUG
- av_log(vc->avccontext, AV_LOG_INFO, "Lookup offset %u ,", i);
-#endif
+ av_dlog(vc->avccontext, "Lookup offset %u ,", i);
for (k = 0; k < dim; ++k) {
unsigned multiplicand_offset = lookup_offset % codebook_lookup_values;
@@ -387,12 +381,11 @@ static int vorbis_parse_setup_hdr_codebooks(vorbis_context *vc)
}
tmp_vlc_bits[j] = tmp_vlc_bits[i];
-#ifdef V_DEBUG
- av_log(vc->avccontext, AV_LOG_INFO, "real lookup offset %u, vector: ", j);
+ av_dlog(vc->avccontext, "real lookup offset %u, vector: ", j);
for (k = 0; k < dim; ++k)
- av_log(vc->avccontext, AV_LOG_INFO, " %f ", codebook_setup->codevectors[j * dim + k]);
- av_log(vc->avccontext, AV_LOG_INFO, "\n");
-#endif
+ av_dlog(vc->avccontext, " %f ",
+ codebook_setup->codevectors[j * dim + k]);
+ av_dlog(vc->avccontext, "\n");
++j;
}
@@ -453,8 +446,8 @@ static int vorbis_parse_setup_hdr_tdtransforms(vorbis_context *vc)
for (i = 0; i < vorbis_time_count; ++i) {
unsigned vorbis_tdtransform = get_bits(gb, 16);
- AV_DEBUG(" Vorbis time domain transform %u: %u\n",
- vorbis_time_count, vorbis_tdtransform);
+ av_dlog(NULL, " Vorbis time domain transform %u: %u\n",
+ vorbis_time_count, vorbis_tdtransform);
if (vorbis_tdtransform) {
av_log(vc->avccontext, AV_LOG_ERROR, "Vorbis time domain transform data nonzero. \n");
@@ -485,7 +478,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
floor_setup->floor_type = get_bits(gb, 16);
- AV_DEBUG(" %d. floor type %d \n", i, floor_setup->floor_type);
+ av_dlog(NULL, " %d. floor type %d \n", i, floor_setup->floor_type);
if (floor_setup->floor_type == 1) {
int maximum_class = -1;
@@ -495,29 +488,33 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
floor_setup->data.t1.partitions = get_bits(gb, 5);
- AV_DEBUG(" %d.floor: %d partitions \n", i, floor_setup->data.t1.partitions);
+ av_dlog(NULL, " %d.floor: %d partitions \n",
+ i, floor_setup->data.t1.partitions);
for (j = 0; j < floor_setup->data.t1.partitions; ++j) {
floor_setup->data.t1.partition_class[j] = get_bits(gb, 4);
if (floor_setup->data.t1.partition_class[j] > maximum_class)
maximum_class = floor_setup->data.t1.partition_class[j];
- AV_DEBUG(" %d. floor %d partition class %d \n", i, j, floor_setup->data.t1.partition_class[j]);
+ av_dlog(NULL, " %d. floor %d partition class %d \n",
+ i, j, floor_setup->data.t1.partition_class[j]);
}
- AV_DEBUG(" maximum class %d \n", maximum_class);
+ av_dlog(NULL, " maximum class %d \n", maximum_class);
for (j = 0; j <= maximum_class; ++j) {
floor_setup->data.t1.class_dimensions[j] = get_bits(gb, 3) + 1;
floor_setup->data.t1.class_subclasses[j] = get_bits(gb, 2);
- AV_DEBUG(" %d floor %d class dim: %d subclasses %d \n", i, j, floor_setup->data.t1.class_dimensions[j], floor_setup->data.t1.class_subclasses[j]);
+ av_dlog(NULL, " %d floor %d class dim: %d subclasses %d \n", i, j,
+ floor_setup->data.t1.class_dimensions[j],
+ floor_setup->data.t1.class_subclasses[j]);
if (floor_setup->data.t1.class_subclasses[j]) {
GET_VALIDATED_INDEX(floor_setup->data.t1.class_masterbook[j], 8, vc->codebook_count)
- AV_DEBUG(" masterbook: %d \n", floor_setup->data.t1.class_masterbook[j]);
+ av_dlog(NULL, " masterbook: %d \n", floor_setup->data.t1.class_masterbook[j]);
}
for (k = 0; k < (1 << floor_setup->data.t1.class_subclasses[j]); ++k) {
@@ -526,7 +523,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
VALIDATE_INDEX(bits, vc->codebook_count)
floor_setup->data.t1.subclass_books[j][k] = bits;
- AV_DEBUG(" book %d. : %d \n", k, floor_setup->data.t1.subclass_books[j][k]);
+ av_dlog(NULL, " book %d. : %d \n", k, floor_setup->data.t1.subclass_books[j][k]);
}
}
@@ -555,8 +552,8 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
for (k = 0; k < floor_setup->data.t1.class_dimensions[floor_setup->data.t1.partition_class[j]]; ++k, ++floor1_values) {
floor_setup->data.t1.list[floor1_values].x = get_bits(gb, rangebits);
- AV_DEBUG(" %u. floor1 Y coord. %d\n", floor1_values,
- floor_setup->data.t1.list[floor1_values].x);
+ av_dlog(NULL, " %u. floor1 Y coord. %d\n", floor1_values,
+ floor_setup->data.t1.list[floor1_values].x);
}
}
@@ -608,28 +605,26 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
if (!floor_setup->data.t0.lsp)
return -1;
-#ifdef V_DEBUG /* debug output parsed headers */
- AV_DEBUG("floor0 order: %u\n", floor_setup->data.t0.order);
- AV_DEBUG("floor0 rate: %u\n", floor_setup->data.t0.rate);
- AV_DEBUG("floor0 bark map size: %u\n",
- floor_setup->data.t0.bark_map_size);
- AV_DEBUG("floor0 amplitude bits: %u\n",
- floor_setup->data.t0.amplitude_bits);
- AV_DEBUG("floor0 amplitude offset: %u\n",
- floor_setup->data.t0.amplitude_offset);
- AV_DEBUG("floor0 number of books: %u\n",
- floor_setup->data.t0.num_books);
- AV_DEBUG("floor0 book list pointer: %p\n",
- floor_setup->data.t0.book_list);
+ /* debug output parsed headers */
+ av_dlog(NULL, "floor0 order: %u\n", floor_setup->data.t0.order);
+ av_dlog(NULL, "floor0 rate: %u\n", floor_setup->data.t0.rate);
+ av_dlog(NULL, "floor0 bark map size: %u\n",
+ floor_setup->data.t0.bark_map_size);
+ av_dlog(NULL, "floor0 amplitude bits: %u\n",
+ floor_setup->data.t0.amplitude_bits);
+ av_dlog(NULL, "floor0 amplitude offset: %u\n",
+ floor_setup->data.t0.amplitude_offset);
+ av_dlog(NULL, "floor0 number of books: %u\n",
+ floor_setup->data.t0.num_books);
+ av_dlog(NULL, "floor0 book list pointer: %p\n",
+ floor_setup->data.t0.book_list);
{
int idx;
for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) {
- AV_DEBUG(" Book %d: %u\n",
- idx+1,
- floor_setup->data.t0.book_list[idx]);
+ av_dlog(NULL, " Book %d: %u\n", idx + 1,
+ floor_setup->data.t0.book_list[idx]);
}
}
-#endif
} else {
av_log(vc->avccontext, AV_LOG_ERROR, "Invalid floor type!\n");
return -1;
@@ -648,7 +643,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
vc->residue_count = get_bits(gb, 6)+1;
vc->residues = av_mallocz(vc->residue_count * sizeof(*vc->residues));
- AV_DEBUG(" There are %d residues. \n", vc->residue_count);
+ av_dlog(NULL, " There are %d residues. \n", vc->residue_count);
for (i = 0; i < vc->residue_count; ++i) {
vorbis_residue *res_setup = &vc->residues[i];
@@ -657,7 +652,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
res_setup->type = get_bits(gb, 16);
- AV_DEBUG(" %u. residue type %d\n", i, res_setup->type);
+ av_dlog(NULL, " %u. residue type %d\n", i, res_setup->type);
res_setup->begin = get_bits(gb, 24);
res_setup->end = get_bits(gb, 24);
@@ -684,8 +679,9 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
if (!res_setup->classifs)
return AVERROR(ENOMEM);
- AV_DEBUG(" begin %d end %d part.size %d classif.s %d classbook %d \n", res_setup->begin, res_setup->end, res_setup->partition_size,
- res_setup->classifications, res_setup->classbook);
+ av_dlog(NULL, " begin %d end %d part.size %d classif.s %d classbook %d \n",
+ res_setup->begin, res_setup->end, res_setup->partition_size,
+ res_setup->classifications, res_setup->classbook);
for (j = 0; j < res_setup->classifications; ++j) {
high_bits = 0;
@@ -694,7 +690,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
high_bits = get_bits(gb, 5);
cascade[j] = (high_bits << 3) + low_bits;
- AV_DEBUG(" %u class cascade depth: %d\n", j, ilog(cascade[j]));
+ av_dlog(NULL, " %u class cascade depth: %d\n", j, ilog(cascade[j]));
}
res_setup->maxpass = 0;
@@ -703,8 +699,8 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
if (cascade[j]&(1 << k)) {
GET_VALIDATED_INDEX(res_setup->books[j][k], 8, vc->codebook_count)
- AV_DEBUG(" %u class cascade depth %u book: %d\n",
- j, k, res_setup->books[j][k]);
+ av_dlog(NULL, " %u class cascade depth %u book: %d\n",
+ j, k, res_setup->books[j][k]);
if (k>res_setup->maxpass)
res_setup->maxpass = k;
@@ -727,7 +723,7 @@ static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc)
vc->mapping_count = get_bits(gb, 6)+1;
vc->mappings = av_mallocz(vc->mapping_count * sizeof(*vc->mappings));
- AV_DEBUG(" There are %d mappings. \n", vc->mapping_count);
+ av_dlog(NULL, " There are %d mappings. \n", vc->mapping_count);
for (i = 0; i < vc->mapping_count; ++i) {
vorbis_mapping *mapping_setup = &vc->mappings[i];
@@ -756,8 +752,8 @@ static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc)
mapping_setup->coupling_steps = 0;
}
- AV_DEBUG(" %u mapping coupling steps: %d\n",
- i, mapping_setup->coupling_steps);
+ av_dlog(NULL, " %u mapping coupling steps: %d\n",
+ i, mapping_setup->coupling_steps);
if (get_bits(gb, 2)) {
av_log(vc->avccontext, AV_LOG_ERROR, "%u. mapping setup data invalid.\n", i);
@@ -776,10 +772,9 @@ static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc)
GET_VALIDATED_INDEX(mapping_setup->submap_floor[j], 8, vc->floor_count)
GET_VALIDATED_INDEX(mapping_setup->submap_residue[j], 8, vc->residue_count)
- AV_DEBUG(" %u mapping %u submap : floor %d, residue %d\n",
- i, j,
- mapping_setup->submap_floor[j],
- mapping_setup->submap_residue[j]);
+ av_dlog(NULL, " %u mapping %u submap : floor %d, residue %d\n", i, j,
+ mapping_setup->submap_floor[j],
+ mapping_setup->submap_residue[j]);
}
}
return 0;
@@ -814,12 +809,9 @@ static void create_map(vorbis_context *vc, unsigned floor_number)
vf->map_size[blockflag] = n;
}
-#ifdef V_DEBUG
for (idx = 0; idx <= n; ++idx) {
- AV_DEBUG("floor0 map: map at pos %d is %d\n",
- idx, map[idx]);
+ av_dlog(NULL, "floor0 map: map at pos %d is %d\n", idx, map[idx]);
}
-#endif
}
static int vorbis_parse_setup_hdr_modes(vorbis_context *vc)
@@ -830,7 +822,7 @@ static int vorbis_parse_setup_hdr_modes(vorbis_context *vc)
vc->mode_count = get_bits(gb, 6) + 1;
vc->modes = av_mallocz(vc->mode_count * sizeof(*vc->modes));
- AV_DEBUG(" There are %d modes.\n", vc->mode_count);
+ av_dlog(NULL, " There are %d modes.\n", vc->mode_count);
for (i = 0; i < vc->mode_count; ++i) {
vorbis_mode *mode_setup = &vc->modes[i];
@@ -840,9 +832,9 @@ static int vorbis_parse_setup_hdr_modes(vorbis_context *vc)
mode_setup->transformtype = get_bits(gb, 16); //FIXME check
GET_VALIDATED_INDEX(mode_setup->mapping, 8, vc->mapping_count);
- AV_DEBUG(" %u mode: blockflag %d, windowtype %d, transformtype %d, mapping %d\n",
- i, mode_setup->blockflag, mode_setup->windowtype,
- mode_setup->transformtype, mode_setup->mapping);
+ av_dlog(NULL, " %u mode: blockflag %d, windowtype %d, transformtype %d, mapping %d\n",
+ i, mode_setup->blockflag, mode_setup->windowtype,
+ mode_setup->transformtype, mode_setup->mapping);
}
return 0;
}
@@ -950,7 +942,7 @@ static int vorbis_parse_id_hdr(vorbis_context *vc)
ff_mdct_init(&vc->mdct[0], bl0, 1, -vc->scale_bias);
ff_mdct_init(&vc->mdct[1], bl1, 1, -vc->scale_bias);
- AV_DEBUG(" vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ",
+ av_dlog(NULL, " vorbis version %d \n audio_channels %d \n audio_samplerate %d \n bitrate_max %d \n bitrate_nom %d \n bitrate_min %d \n blk_0 %d blk_1 %d \n ",
vc->version, vc->audio_channels, vc->audio_samplerate, vc->bitrate_maximum, vc->bitrate_nominal, vc->bitrate_minimum, vc->blocksize[0], vc->blocksize[1]);
/*
@@ -1058,7 +1050,7 @@ static int vorbis_floor0_decode(vorbis_context *vc,
"floor0 dec: booknumber too high!\n");
book_idx = 0;
}
- AV_DEBUG("floor0 dec: booknumber: %u\n", book_idx);
+ av_dlog(NULL, "floor0 dec: booknumber: %u\n", book_idx);
codebook = vc->codebooks[vf->book_list[book_idx]];
/* Invalid codebook! */
if (!codebook.codevectors)
@@ -1067,13 +1059,13 @@ static int vorbis_floor0_decode(vorbis_context *vc,
while (lsp_len<vf->order) {
int vec_off;
- AV_DEBUG("floor0 dec: book dimension: %d\n", codebook.dimensions);
- AV_DEBUG("floor0 dec: maximum depth: %d\n", codebook.maxdepth);
+ av_dlog(NULL, "floor0 dec: book dimension: %d\n", codebook.dimensions);
+ av_dlog(NULL, "floor0 dec: maximum depth: %d\n", codebook.maxdepth);
/* read temp vector */
vec_off = get_vlc2(&vc->gb, codebook.vlc.table,
codebook.nb_bits, codebook.maxdepth)
* codebook.dimensions;
- AV_DEBUG("floor0 dec: vector offset: %d\n", vec_off);
+ av_dlog(NULL, "floor0 dec: vector offset: %d\n", vec_off);
/* copy each vector component and add last to it */
for (idx = 0; idx < codebook.dimensions; ++idx)
lsp[lsp_len+idx] = codebook.codevectors[vec_off+idx] + last;
@@ -1081,14 +1073,12 @@ static int vorbis_floor0_decode(vorbis_context *vc,
lsp_len += codebook.dimensions;
}
-#ifdef V_DEBUG
/* DEBUG: output lsp coeffs */
{
int idx;
for (idx = 0; idx < lsp_len; ++idx)
- AV_DEBUG("floor0 dec: coeff at %d is %f\n", idx, lsp[idx]);
+ av_dlog(NULL, "floor0 dec: coeff at %d is %f\n", idx, lsp[idx]);
}
-#endif
/* synthesize floor output vector */
{
@@ -1099,9 +1089,6 @@ static int vorbis_floor0_decode(vorbis_context *vc,
for (i = 0; i < order; i++)
lsp[i] = 2.0f * cos(lsp[i]);
- AV_DEBUG("floor0 synth: map_size = %d; m = %d; wstep = %f\n",
- vf->map_size, order, wstep);
-
i = 0;
while (i < vf->map_size[blockflag]) {
int j, iter_cond = vf->map[blockflag][i];
@@ -1141,7 +1128,7 @@ static int vorbis_floor0_decode(vorbis_context *vc,
return 1;
}
- AV_DEBUG(" Floor0 decoded\n");
+ av_dlog(NULL, " Floor0 decoded\n");
return 0;
}
@@ -1168,7 +1155,7 @@ static int vorbis_floor1_decode(vorbis_context *vc,
floor1_Y[0] = get_bits(gb, ilog(range - 1));
floor1_Y[1] = get_bits(gb, ilog(range - 1));
- AV_DEBUG("floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]);
+ av_dlog(NULL, "floor 0 Y %d floor 1 Y %d \n", floor1_Y[0], floor1_Y[1]);
offset = 2;
for (i = 0; i < vf->partitions; ++i) {
@@ -1178,7 +1165,7 @@ static int vorbis_floor1_decode(vorbis_context *vc,
csub = (1 << cbits) - 1;
cval = 0;
- AV_DEBUG("Cbits %u\n", cbits);
+ av_dlog(NULL, "Cbits %u\n", cbits);
if (cbits) // this reads all subclasses for this partition's class
cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[partition_class]].vlc.table,
@@ -1187,8 +1174,8 @@ static int vorbis_floor1_decode(vorbis_context *vc,
for (j = 0; j < cdim; ++j) {
book = vf->subclass_books[partition_class][cval & csub];
- AV_DEBUG("book %d Cbits %u cval %u bits:%d\n",
- book, cbits, cval, get_bits_count(gb));
+ av_dlog(NULL, "book %d Cbits %u cval %u bits:%d\n",
+ book, cbits, cval, get_bits_count(gb));
cval = cval >> cbits;
if (book > -1) {
@@ -1198,7 +1185,8 @@ static int vorbis_floor1_decode(vorbis_context *vc,
floor1_Y[offset+j] = 0;
}
- AV_DEBUG(" floor(%d) = %d \n", vf->list[offset+j].x, floor1_Y[offset+j]);
+ av_dlog(NULL, " floor(%d) = %d \n",
+ vf->list[offset+j].x, floor1_Y[offset+j]);
}
offset+=cdim;
}
@@ -1256,15 +1244,15 @@ static int vorbis_floor1_decode(vorbis_context *vc,
floor1_Y_final[i] = predicted;
}
- AV_DEBUG(" Decoded floor(%d) = %u / val %u\n",
- vf->list[i].x, floor1_Y_final[i], val);
+ av_dlog(NULL, " Decoded floor(%d) = %u / val %u\n",
+ vf->list[i].x, floor1_Y_final[i], val);
}
// Curve synth - connect the calculated dots and convert from dB scale FIXME optimize ?
ff_vorbis_floor1_render_list(vf->list, vf->x_list_dim, floor1_Y_final, floor1_flag, vf->multiplier, vec, vf->list[1].x);
- AV_DEBUG(" Floor decoded\n");
+ av_dlog(NULL, " Floor decoded\n");
return 0;
}
@@ -1295,7 +1283,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
ch_used = ch;
}
- AV_DEBUG(" residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c);
+ av_dlog(NULL, " residue type 0/1/2 decode begin, ch: %d cpc %d \n", ch, c_p_c);
for (pass = 0; pass <= vr->maxpass; ++pass) { // FIXME OPTIMIZE?
uint16_t voffset, partition_count, j_times_ptns_to_read;
@@ -1309,7 +1297,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
unsigned temp = get_vlc2(gb, vc->codebooks[vr->classbook].vlc.table,
vc->codebooks[vr->classbook].nb_bits, 3);
- AV_DEBUG("Classword: %u\n", temp);
+ av_dlog(NULL, "Classword: %u\n", temp);
assert(vr->classifications > 1 && temp <= 65536); //needed for inverse[]
for (i = 0; i < c_p_c; ++i) {
@@ -1354,7 +1342,8 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
for (l = 0; l < dim; ++l, ++voffs) {
vec[voffs]+=codebook.codevectors[coffs+l]; // FPMATH
- AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d \n", pass, voffs, vec[voffs], codebook.codevectors[coffs+l], coffs);
+ av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d \n",
+ pass, voffs, vec[voffs], codebook.codevectors[coffs+l], coffs);
}
}
} else if (vr_type == 2 && ch == 2 && (voffset & 1) == 0 && (dim & 1) == 0) { // most frequent case optimized
@@ -1381,7 +1370,10 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
vec[voffs ] += codebook.codevectors[coffs + l ]; // FPMATH
vec[voffs + vlen] += codebook.codevectors[coffs + l + 1]; // FPMATH
- AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n", pass, voffset / ch + (voffs % ch) * vlen, vec[voffset / ch + (voffs % ch) * vlen], codebook.codevectors[coffs + l], coffs, l);
+ av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n",
+ pass, voffset / ch + (voffs % ch) * vlen,
+ vec[voffset / ch + (voffs % ch) * vlen],
+ codebook.codevectors[coffs + l], coffs, l);
}
}
@@ -1393,7 +1385,10 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
for (l = 0; l < dim; ++l, ++voffs) {
vec[voffs / ch + (voffs % ch) * vlen] += codebook.codevectors[coffs + l]; // FPMATH FIXME use if and counter instead of / and %
- AV_DEBUG(" pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n", pass, voffset / ch + (voffs % ch) * vlen, vec[voffset / ch + (voffs % ch) * vlen], codebook.codevectors[coffs + l], coffs, l);
+ av_dlog(NULL, " pass %d offs: %d curr: %f change: %f cv offs.: %d+%d \n",
+ pass, voffset / ch + (voffs % ch) * vlen,
+ vec[voffset / ch + (voffs % ch) * vlen],
+ codebook.codevectors[coffs + l], coffs, l);
}
}
}
@@ -1481,8 +1476,8 @@ static int vorbis_parse_audio_packet(vorbis_context *vc)
vc->mode_number = mode_number;
mapping = &vc->mappings[vc->modes[mode_number].mapping];
- AV_DEBUG(" Mode number: %u , mapping: %d , blocktype %d\n", mode_number,
- vc->modes[mode_number].mapping, vc->modes[mode_number].blockflag);
+ av_dlog(NULL, " Mode number: %u , mapping: %d , blocktype %d\n", mode_number,
+ vc->modes[mode_number].mapping, vc->modes[mode_number].blockflag);
blockflag = vc->modes[mode_number].blockflag;
blocksize = vc->blocksize[blockflag];
@@ -1611,7 +1606,7 @@ static int vorbis_decode_frame(AVCodecContext *avccontext,
if (!buf_size)
return 0;
- AV_DEBUG("packet length %d \n", buf_size);
+ av_dlog(NULL, "packet length %d \n", buf_size);
init_get_bits(gb, buf, buf_size*8);
@@ -1628,7 +1623,8 @@ static int vorbis_decode_frame(AVCodecContext *avccontext,
return buf_size ;
}
- AV_DEBUG("parsed %d bytes %d bits, returned %d samples (*ch*bits) \n", get_bits_count(gb)/8, get_bits_count(gb)%8, len);
+ av_dlog(NULL, "parsed %d bytes %d bits, returned %d samples (*ch*bits) \n",
+ get_bits_count(gb) / 8, get_bits_count(gb) % 8, len);
if (vc->audio_channels > 8) {
for (i = 0; i < vc->audio_channels; i++)
diff --git a/libavcodec/vqavideo.c b/libavcodec/vqavideo.c
index 272d80906e..ca4fd94d75 100644
--- a/libavcodec/vqavideo.c
+++ b/libavcodec/vqavideo.c
@@ -90,14 +90,6 @@
#define CPLZ_TAG MKBETAG('C', 'P', 'L', 'Z')
#define VPTZ_TAG MKBETAG('V', 'P', 'T', 'Z')
-#define VQA_DEBUG 0
-
-#if VQA_DEBUG
-#define vqa_debug printf
-#else
-static inline void vqa_debug(const char *format, ...) { }
-#endif
-
typedef struct VqaContext {
AVCodecContext *avctx;
@@ -213,7 +205,7 @@ static void decode_format80(const unsigned char *src, int src_size,
while (src_index < src_size) {
- vqa_debug(" opcode %02X: ", src[src_index]);
+ av_dlog(NULL, " opcode %02X: ", src[src_index]);
/* 0x80 means that frame is finished */
if (src[src_index] == 0x80)
@@ -232,7 +224,7 @@ static void decode_format80(const unsigned char *src, int src_size,
src_index += 2;
src_pos = AV_RL16(&src[src_index]);
src_index += 2;
- vqa_debug("(1) copy %X bytes from absolute pos %X\n", count, src_pos);
+ av_dlog(NULL, "(1) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[src_pos + i];
@@ -244,7 +236,7 @@ static void decode_format80(const unsigned char *src, int src_size,
count = AV_RL16(&src[src_index]);
src_index += 2;
color = src[src_index++];
- vqa_debug("(2) set %X bytes to %02X\n", count, color);
+ av_dlog(NULL, "(2) set %X bytes to %02X\n", count, color);
CHECK_COUNT();
memset(&dest[dest_index], color, count);
dest_index += count;
@@ -254,7 +246,7 @@ static void decode_format80(const unsigned char *src, int src_size,
count = (src[src_index++] & 0x3F) + 3;
src_pos = AV_RL16(&src[src_index]);
src_index += 2;
- vqa_debug("(3) copy %X bytes from absolute pos %X\n", count, src_pos);
+ av_dlog(NULL, "(3) copy %X bytes from absolute pos %X\n", count, src_pos);
CHECK_COUNT();
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[src_pos + i];
@@ -263,7 +255,7 @@ static void decode_format80(const unsigned char *src, int src_size,
} else if (src[src_index] > 0x80) {
count = src[src_index++] & 0x3F;
- vqa_debug("(4) copy %X bytes from source to dest\n", count);
+ av_dlog(NULL, "(4) copy %X bytes from source to dest\n", count);
CHECK_COUNT();
memcpy(&dest[dest_index], &src[src_index], count);
src_index += count;
@@ -274,7 +266,7 @@ static void decode_format80(const unsigned char *src, int src_size,
count = ((src[src_index] & 0x70) >> 4) + 3;
src_pos = AV_RB16(&src[src_index]) & 0x0FFF;
src_index += 2;
- vqa_debug("(5) copy %X bytes from relpos %X\n", count, src_pos);
+ av_dlog(NULL, "(5) copy %X bytes from relpos %X\n", count, src_pos);
CHECK_COUNT();
for (i = 0; i < count; i++)
dest[dest_index + i] = dest[dest_index - src_pos + i];
diff --git a/libavcodec/x86/h264_idct_10bit.asm b/libavcodec/x86/h264_idct_10bit.asm
index 3d0004e09e..3f7cf4cefc 100644
--- a/libavcodec/x86/h264_idct_10bit.asm
+++ b/libavcodec/x86/h264_idct_10bit.asm
@@ -133,7 +133,7 @@ ADD4x4IDCT avx
%macro ADD16_OP 3
cmp byte [r4+%3], 0
jz .skipblock%2
- mov r5d, dword [r1+%2*4]
+ mov r5d, [r1+%2*4]
call add4x4_idct_%1
.skipblock%2:
%if %2<15
@@ -159,7 +159,7 @@ cglobal h264_idct_add16_10_%1, 5,6
ADD16_OP %1, 13, 7+3*8
ADD16_OP %1, 14, 6+4*8
ADD16_OP %1, 15, 7+4*8
- RET
+ REP_RET
%endmacro
INIT_XMM
@@ -201,7 +201,7 @@ IDCT_ADD16_10 avx
INIT_MMX
cglobal h264_idct_dc_add_10_mmx2,3,3
- movd m0, dword [r1]
+ movd m0, [r1]
paddd m0, [pd_32]
psrad m0, 6
lea r1, [r2*3]
@@ -215,7 +215,7 @@ cglobal h264_idct_dc_add_10_mmx2,3,3
;-----------------------------------------------------------------------------
%macro IDCT8_DC_ADD 1
cglobal h264_idct8_dc_add_10_%1,3,3,7
- mov r1d, dword [r1]
+ mov r1d, [r1]
add r1, 32
sar r1, 6
movd m0, r1d
@@ -240,26 +240,27 @@ IDCT8_DC_ADD avx
;-----------------------------------------------------------------------------
%macro AC 2
.ac%2
- mov r5d, dword [r1+(%2+0)*4]
+ mov r5d, [r1+(%2+0)*4]
call add4x4_idct_%1
- mov r5d, dword [r1+(%2+1)*4]
+ mov r5d, [r1+(%2+1)*4]
add r2, 64
call add4x4_idct_%1
add r2, 64
jmp .skipadd%2
%endmacro
+%assign last_block 16
%macro ADD16_OP_INTRA 3
- cmp word [r4+%3], 0
+ cmp word [r4+%3], 0
jnz .ac%2
- mov r6d, dword [r2+ 0]
- or r6d, dword [r2+64]
+ mov r5d, [r2+ 0]
+ or r5d, [r2+64]
jz .skipblock%2
- mov r5d, dword [r1+(%2+0)*4]
+ mov r5d, [r1+(%2+0)*4]
call idct_dc_add_%1
.skipblock%2:
-%if %2<15
- add r2, 128
+%if %2<last_block-2
+ add r2, 128
%endif
.skipadd%2:
%endmacro
@@ -287,12 +288,15 @@ cglobal h264_idct_add16intra_10_%1,5,7,8
ADD16_OP_INTRA %1, 10, 4+4*8
ADD16_OP_INTRA %1, 12, 6+3*8
ADD16_OP_INTRA %1, 14, 6+4*8
- RET
-%assign i 14
-%rep 8
- AC %1, i
-%assign i i-2
-%endrep
+ REP_RET
+ AC %1, 8
+ AC %1, 10
+ AC %1, 12
+ AC %1, 14
+ AC %1, 0
+ AC %1, 2
+ AC %1, 4
+ AC %1, 6
%endmacro
INIT_XMM
@@ -302,47 +306,33 @@ INIT_AVX
IDCT_ADD16INTRA_10 avx
%endif
+%assign last_block 24
;-----------------------------------------------------------------------------
; h264_idct_add8(pixel **dst, const int *block_offset, dctcoef *block, int stride, const uint8_t nnzc[6*8])
;-----------------------------------------------------------------------------
%macro IDCT_ADD8 1
cglobal h264_idct_add8_10_%1,5,7
- mov r5, 16
- add r2, 1024
-%ifdef PIC
- lea r11, [scan8_mem]
-%endif
-%ifdef ARCH_X86_64
- mov r10, r0
-%endif
-.nextblock:
- movzx r6, byte [scan8+r5]
- movzx r6, byte [r4+r6]
- or r6d, dword [r2]
- test r6, r6
- jz .skipblock
%ifdef ARCH_X86_64
- mov r0d, dword [r1+r5*4]
- add r0, [r10]
-%else
- mov r0, r0m
- mov r0, [r0]
- add r0, dword [r1+r5*4]
+ mov r10, r0
%endif
- IDCT4_ADD_10 r0, r2, r3
-.skipblock:
- inc r5
- add r2, 64
- test r5, 3
- jnz .nextblock
+ add r2, 1024
+ mov r0, [r0]
+ ADD16_OP_INTRA %1, 16, 1+1*8
+ ADD16_OP_INTRA %1, 18, 1+2*8
%ifdef ARCH_X86_64
- add r10, gprsize
+ mov r0, [r10+gprsize]
%else
- add r0mp, gprsize
+ mov r0, r0m
+ mov r0, [r0+gprsize]
%endif
- test r5, 4
- jnz .nextblock
+ ADD16_OP_INTRA %1, 20, 1+4*8
+ ADD16_OP_INTRA %1, 22, 1+5*8
REP_RET
+ AC %1, 16
+ AC %1, 18
+ AC %1, 20
+ AC %1, 22
+
%endmacro ; IDCT_ADD8
INIT_XMM
@@ -356,51 +346,51 @@ IDCT_ADD8 avx
; void h264_idct8_add(pixel *dst, dctcoef *block, int stride)
;-----------------------------------------------------------------------------
%macro IDCT8_1D 2
- SWAP 0, 1
- psrad m4, m5, 1
- psrad m1, m0, 1
- paddd m4, m5
- paddd m1, m0
- paddd m4, m7
- paddd m1, m5
- psubd m4, m0
- paddd m1, m3
-
- psubd m0, m3
- psubd m5, m3
- paddd m0, m7
- psubd m5, m7
- psrad m3, 1
- psrad m7, 1
- psubd m0, m3
- psubd m5, m7
-
- SWAP 1, 7
- psrad m1, m7, 2
- psrad m3, m4, 2
- paddd m3, m0
- psrad m0, 2
- paddd m1, m5
- psrad m5, 2
- psubd m0, m4
- psubd m7, m5
-
- SWAP 5, 6
- psrad m4, m2, 1
- psrad m6, m5, 1
- psubd m4, m5
- paddd m6, m2
-
- mova m2, %1
- mova m5, %2
- SUMSUB_BA d, 5, 2
- SUMSUB_BA d, 6, 5
- SUMSUB_BA d, 4, 2
- SUMSUB_BA d, 7, 6
- SUMSUB_BA d, 0, 4
- SUMSUB_BA d, 3, 2
- SUMSUB_BA d, 1, 5
- SWAP 7, 6, 4, 5, 2, 3, 1, 0 ; 70315246 -> 01234567
+ SWAP 0, 1
+ psrad m4, m5, 1
+ psrad m1, m0, 1
+ paddd m4, m5
+ paddd m1, m0
+ paddd m4, m7
+ paddd m1, m5
+ psubd m4, m0
+ paddd m1, m3
+
+ psubd m0, m3
+ psubd m5, m3
+ paddd m0, m7
+ psubd m5, m7
+ psrad m3, 1
+ psrad m7, 1
+ psubd m0, m3
+ psubd m5, m7
+
+ SWAP 1, 7
+ psrad m1, m7, 2
+ psrad m3, m4, 2
+ paddd m3, m0
+ psrad m0, 2
+ paddd m1, m5
+ psrad m5, 2
+ psubd m0, m4
+ psubd m7, m5
+
+ SWAP 5, 6
+ psrad m4, m2, 1
+ psrad m6, m5, 1
+ psubd m4, m5
+ paddd m6, m2
+
+ mova m2, %1
+ mova m5, %2
+ SUMSUB_BA d, 5, 2
+ SUMSUB_BA d, 6, 5
+ SUMSUB_BA d, 4, 2
+ SUMSUB_BA d, 7, 6
+ SUMSUB_BA d, 0, 4
+ SUMSUB_BA d, 3, 2
+ SUMSUB_BA d, 1, 5
+ SWAP 7, 6, 4, 5, 2, 3, 1, 0 ; 70315246 -> 01234567
%endmacro
%macro IDCT8_1D_FULL 1
@@ -536,7 +526,7 @@ IDCT8_ADD avx
%macro IDCT8_ADD4_OP 3
cmp byte [r4+%3], 0
jz .skipblock%2
- mov r0d, dword [r6+%2*4]
+ mov r0d, [r6+%2*4]
add r0, r5
call h264_idct8_add1_10_%1
.skipblock%2:
diff --git a/libavcodec/x86/h264_intrapred.asm b/libavcodec/x86/h264_intrapred.asm
index 191eb8ddf2..a9da6a19db 100644
--- a/libavcodec/x86/h264_intrapred.asm
+++ b/libavcodec/x86/h264_intrapred.asm
@@ -836,7 +836,6 @@ PRED8x8_H ssse3
;-----------------------------------------------------------------------------
; void pred8x8_top_dc_mmxext(uint8_t *src, int stride)
;-----------------------------------------------------------------------------
-%ifdef CONFIG_GPL
cglobal pred8x8_top_dc_mmxext, 2,5
sub r0, r1
movq mm0, [r0]
@@ -927,7 +926,6 @@ cglobal pred8x8_dc_mmxext, 2,5
movq [r4+r1*1], m1
movq [r4+r1*2], m1
RET
-%endif
;-----------------------------------------------------------------------------
; void pred8x8_dc_rv40(uint8_t *src, int stride)
@@ -1083,7 +1081,6 @@ cglobal pred8x8_tm_vp8_ssse3, 2,3,6
;-----------------------------------------------------------------------------
; void pred8x8l_top_dc(uint8_t *src, int has_topleft, int has_topright, int stride)
;-----------------------------------------------------------------------------
-%ifdef CONFIG_GPL
%macro PRED8x8L_TOP_DC 1
cglobal pred8x8l_top_dc_%1, 4,4
sub r0, r3
@@ -2476,7 +2473,6 @@ PRED8x8L_HORIZONTAL_DOWN sse2
INIT_MMX
%define PALIGNR PALIGNR_SSSE3
PRED8x8L_HORIZONTAL_DOWN ssse3
-%endif
;-----------------------------------------------------------------------------
; void pred4x4_dc_mmxext(uint8_t *src, const uint8_t *topright, int stride)
@@ -2608,7 +2604,6 @@ cglobal pred4x4_vertical_vp8_mmxext, 3,3
;-----------------------------------------------------------------------------
; void pred4x4_down_left_mmxext(uint8_t *src, const uint8_t *topright, int stride)
;-----------------------------------------------------------------------------
-%ifdef CONFIG_GPL
INIT_MMX
cglobal pred4x4_down_left_mmxext, 3,3
sub r0, r2
@@ -2786,4 +2781,3 @@ cglobal pred4x4_down_right_mmxext, 3,3
psrlq m0, 8
movh [r0+r2*1], m0
RET
-%endif
diff --git a/libavcodec/x86/h264_intrapred_init.c b/libavcodec/x86/h264_intrapred_init.c
index fa5b86fc3e..f001242315 100644
--- a/libavcodec/x86/h264_intrapred_init.c
+++ b/libavcodec/x86/h264_intrapred_init.c
@@ -129,7 +129,6 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_mmxext;
h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_mmxext;
h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_mmxext;
-#if CONFIG_GPL
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;
@@ -142,9 +141,7 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth
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;
-#endif
h->pred4x4 [DC_PRED ] = ff_pred4x4_dc_mmxext;
-#if CONFIG_GPL
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)
@@ -156,7 +153,6 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth
h->pred8x8 [TOP_DC_PRED8x8 ] = ff_pred8x8_top_dc_mmxext;
h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_mmxext;
}
-#endif
if (codec_id == CODEC_ID_VP8) {
h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_mmxext;
h->pred8x8 [DC_PRED8x8 ] = ff_pred8x8_dc_rv40_mmxext;
@@ -181,13 +177,11 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth
if (mm_flags & AV_CPU_FLAG_SSE2) {
h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_sse2;
-#if CONFIG_GPL
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;
-#endif
if (codec_id == CODEC_ID_VP8) {
h->pred16x16[PLANE_PRED8x8] = ff_pred16x16_tm_vp8_sse2;
h->pred8x8 [PLANE_PRED8x8] = ff_pred8x8_tm_vp8_sse2;
@@ -207,7 +201,6 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth
h->pred16x16[HOR_PRED8x8 ] = ff_pred16x16_horizontal_ssse3;
h->pred16x16[DC_PRED8x8 ] = ff_pred16x16_dc_ssse3;
h->pred8x8 [HOR_PRED8x8 ] = ff_pred8x8_horizontal_ssse3;
-#if CONFIG_GPL
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;
@@ -218,7 +211,6 @@ void ff_h264_pred_init_x86(H264PredContext *h, int codec_id, const int bit_depth
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;
-#endif
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;