1
0
mirror of https://github.com/FFmpeg/FFmpeg.git synced 2024-12-23 12:43:46 +02:00

Replace custom debug output functions by av_dlog().

This commit is contained in:
Diego Biurrun 2011-06-02 22:49:53 +02:00
parent 752207e36b
commit df96f22d8f
4 changed files with 161 additions and 181 deletions

View File

@ -46,14 +46,6 @@
#define PALETTE_COUNT 256 #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 { typedef struct IpvideoContext {
AVCodecContext *avctx; AVCodecContext *avctx;
@ -141,7 +133,7 @@ static int ipvideo_decode_block_opcode_0x2(IpvideoContext *s)
y = 8 + ((B - 56) / 29); 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); 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)); 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); 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; x = -8 + BL;
y = -8 + BH; 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); 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++; x = *s->stream_ptr++;
y = *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); 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++; x = *s->stream_ptr++;
y = *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); 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; static int frame = 0;
GetBitContext gb; GetBitContext gb;
debug_interplay("------------------ frame %d\n", frame); av_dlog(NULL, "------------------ frame %d\n", frame);
frame++; frame++;
if (!s->is_16bpp) { if (!s->is_16bpp) {
@ -991,8 +983,8 @@ static void ipvideo_decode_opcodes(IpvideoContext *s)
for (x = 0; x < s->avctx->width; x += 8) { for (x = 0; x < s->avctx->width; x += 8) {
opcode = get_bits(&gb, 4); opcode = get_bits(&gb, 4);
debug_interplay(" block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n", av_dlog(NULL, " block @ (%3d, %3d): encoding 0x%X, data ptr @ %p\n",
x, y, opcode, s->stream_ptr); x, y, opcode, s->stream_ptr);
if (!s->is_16bpp) { if (!s->is_16bpp) {
s->pixel_ptr = s->current_frame.data[0] + x s->pixel_ptr = s->current_frame.data[0] + x

View File

@ -20,10 +20,6 @@
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA * 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> #include <math.h>
#define ALT_BITSTREAM_READER_LE #define ALT_BITSTREAM_READER_LE
@ -41,10 +37,6 @@
#define V_MAX_VLCS (1 << 16) #define V_MAX_VLCS (1 << 16)
#define V_MAX_PARTITIONS (1 << 20) #define V_MAX_PARTITIONS (1 << 20)
#ifndef V_DEBUG
#define AV_DEBUG(...)
#endif
#undef NDEBUG #undef NDEBUG
#include <assert.h> #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; 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)); vc->codebooks = av_mallocz(vc->codebook_count * sizeof(*vc->codebooks));
tmp_vlc_bits = av_mallocz(V_MAX_VLCS * sizeof(*tmp_vlc_bits)); 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]; vorbis_codebook *codebook_setup = &vc->codebooks[cb];
unsigned ordered, t, entries, used_entries = 0; 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) { if (get_bits(gb, 24) != 0x564342) {
av_log(vc->avccontext, AV_LOG_ERROR, 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); ordered = get_bits1(gb);
AV_DEBUG(" codebook_dimensions %d, codebook_entries %u\n", av_dlog(NULL, " codebook_dimensions %d, codebook_entries %u\n",
codebook_setup->dimensions, entries); codebook_setup->dimensions, entries);
if (!ordered) { if (!ordered) {
unsigned ce, flag; unsigned ce, flag;
unsigned sparse = get_bits1(gb); unsigned sparse = get_bits1(gb);
AV_DEBUG(" not ordered \n"); av_dlog(NULL, " not ordered \n");
if (sparse) { if (sparse) {
AV_DEBUG(" sparse \n"); av_dlog(NULL, " sparse \n");
used_entries = 0; used_entries = 0;
for (ce = 0; ce < entries; ++ce) { 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; tmp_vlc_bits[ce] = 0;
} }
} else { } else {
AV_DEBUG(" not sparse \n"); av_dlog(NULL, " not sparse \n");
used_entries = entries; used_entries = entries;
for (ce = 0; ce < entries; ++ce) 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_entry = 0;
unsigned current_length = get_bits(gb, 5) + 1; 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; used_entries = entries;
for (; current_entry < used_entries && current_length <= 32; ++current_length) { for (; current_entry < used_entries && current_length <= 32; ++current_length) {
unsigned i, number; 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)); 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) for (i = current_entry; i < number+current_entry; ++i)
if (i < used_entries) 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); 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. // 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_value_bits = get_bits(gb, 4) + 1;
unsigned codebook_sequence_p = get_bits1(gb); unsigned codebook_sequence_p = get_bits1(gb);
AV_DEBUG(" We expect %d numbers for building the codevectors. \n", codebook_lookup_values); av_dlog(NULL, " We expect %d numbers for building the codevectors. \n",
AV_DEBUG(" delta %f minmum %f \n", codebook_delta_value, codebook_minimum_value); 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) { for (i = 0; i < codebook_lookup_values; ++i) {
codebook_multiplicands[i] = get_bits(gb, codebook_value_bits); 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_dlog(NULL, " multiplicands*delta+minmum : %e \n",
AV_DEBUG(" multiplicand %u\n", codebook_multiplicands[i]); (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 // Weed out unused vlcs and build codevector vector
@ -453,8 +449,8 @@ static int vorbis_parse_setup_hdr_tdtransforms(vorbis_context *vc)
for (i = 0; i < vorbis_time_count; ++i) { for (i = 0; i < vorbis_time_count; ++i) {
unsigned vorbis_tdtransform = get_bits(gb, 16); unsigned vorbis_tdtransform = get_bits(gb, 16);
AV_DEBUG(" Vorbis time domain transform %u: %u\n", av_dlog(NULL, " Vorbis time domain transform %u: %u\n",
vorbis_time_count, vorbis_tdtransform); vorbis_time_count, vorbis_tdtransform);
if (vorbis_tdtransform) { if (vorbis_tdtransform) {
av_log(vc->avccontext, AV_LOG_ERROR, "Vorbis time domain transform data nonzero. \n"); av_log(vc->avccontext, AV_LOG_ERROR, "Vorbis time domain transform data nonzero. \n");
@ -485,7 +481,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
floor_setup->floor_type = get_bits(gb, 16); 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) { if (floor_setup->floor_type == 1) {
int maximum_class = -1; int maximum_class = -1;
@ -495,29 +491,33 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
floor_setup->data.t1.partitions = get_bits(gb, 5); 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) { for (j = 0; j < floor_setup->data.t1.partitions; ++j) {
floor_setup->data.t1.partition_class[j] = get_bits(gb, 4); floor_setup->data.t1.partition_class[j] = get_bits(gb, 4);
if (floor_setup->data.t1.partition_class[j] > maximum_class) if (floor_setup->data.t1.partition_class[j] > maximum_class)
maximum_class = floor_setup->data.t1.partition_class[j]; 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) { for (j = 0; j <= maximum_class; ++j) {
floor_setup->data.t1.class_dimensions[j] = get_bits(gb, 3) + 1; floor_setup->data.t1.class_dimensions[j] = get_bits(gb, 3) + 1;
floor_setup->data.t1.class_subclasses[j] = get_bits(gb, 2); 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]) { if (floor_setup->data.t1.class_subclasses[j]) {
GET_VALIDATED_INDEX(floor_setup->data.t1.class_masterbook[j], 8, vc->codebook_count) 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) { for (k = 0; k < (1 << floor_setup->data.t1.class_subclasses[j]); ++k) {
@ -526,7 +526,7 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
VALIDATE_INDEX(bits, vc->codebook_count) VALIDATE_INDEX(bits, vc->codebook_count)
floor_setup->data.t1.subclass_books[j][k] = bits; 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 +555,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) { 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); floor_setup->data.t1.list[floor1_values].x = get_bits(gb, rangebits);
AV_DEBUG(" %u. floor1 Y coord. %d\n", floor1_values, av_dlog(NULL, " %u. floor1 Y coord. %d\n", floor1_values,
floor_setup->data.t1.list[floor1_values].x); floor_setup->data.t1.list[floor1_values].x);
} }
} }
@ -609,24 +609,24 @@ static int vorbis_parse_setup_hdr_floors(vorbis_context *vc)
return -1; return -1;
#ifdef V_DEBUG /* debug output parsed headers */ #ifdef V_DEBUG /* debug output parsed headers */
AV_DEBUG("floor0 order: %u\n", floor_setup->data.t0.order); /* debug output parsed headers */
AV_DEBUG("floor0 rate: %u\n", floor_setup->data.t0.rate); av_dlog(NULL, "floor0 order: %u\n", floor_setup->data.t0.order);
AV_DEBUG("floor0 bark map size: %u\n", av_dlog(NULL, "floor0 rate: %u\n", floor_setup->data.t0.rate);
floor_setup->data.t0.bark_map_size); av_dlog(NULL, "floor0 bark map size: %u\n",
AV_DEBUG("floor0 amplitude bits: %u\n", floor_setup->data.t0.bark_map_size);
floor_setup->data.t0.amplitude_bits); av_dlog(NULL, "floor0 amplitude bits: %u\n",
AV_DEBUG("floor0 amplitude offset: %u\n", floor_setup->data.t0.amplitude_bits);
floor_setup->data.t0.amplitude_offset); av_dlog(NULL, "floor0 amplitude offset: %u\n",
AV_DEBUG("floor0 number of books: %u\n", floor_setup->data.t0.amplitude_offset);
floor_setup->data.t0.num_books); av_dlog(NULL, "floor0 number of books: %u\n",
AV_DEBUG("floor0 book list pointer: %p\n", floor_setup->data.t0.num_books);
floor_setup->data.t0.book_list); av_dlog(NULL, "floor0 book list pointer: %p\n",
floor_setup->data.t0.book_list);
{ {
int idx; int idx;
for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) { for (idx = 0; idx < floor_setup->data.t0.num_books; ++idx) {
AV_DEBUG(" Book %d: %u\n", av_dlog(NULL, " Book %d: %u\n", idx + 1,
idx+1, floor_setup->data.t0.book_list[idx]);
floor_setup->data.t0.book_list[idx]);
} }
} }
#endif #endif
@ -648,7 +648,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
vc->residue_count = get_bits(gb, 6)+1; vc->residue_count = get_bits(gb, 6)+1;
vc->residues = av_mallocz(vc->residue_count * sizeof(*vc->residues)); 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) { for (i = 0; i < vc->residue_count; ++i) {
vorbis_residue *res_setup = &vc->residues[i]; vorbis_residue *res_setup = &vc->residues[i];
@ -657,7 +657,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
res_setup->type = get_bits(gb, 16); 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->begin = get_bits(gb, 24);
res_setup->end = get_bits(gb, 24); res_setup->end = get_bits(gb, 24);
@ -684,8 +684,9 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
if (!res_setup->classifs) if (!res_setup->classifs)
return AVERROR(ENOMEM); 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, av_dlog(NULL, " begin %d end %d part.size %d classif.s %d classbook %d \n",
res_setup->classifications, res_setup->classbook); res_setup->begin, res_setup->end, res_setup->partition_size,
res_setup->classifications, res_setup->classbook);
for (j = 0; j < res_setup->classifications; ++j) { for (j = 0; j < res_setup->classifications; ++j) {
high_bits = 0; high_bits = 0;
@ -694,7 +695,7 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
high_bits = get_bits(gb, 5); high_bits = get_bits(gb, 5);
cascade[j] = (high_bits << 3) + low_bits; 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; res_setup->maxpass = 0;
@ -703,8 +704,8 @@ static int vorbis_parse_setup_hdr_residues(vorbis_context *vc)
if (cascade[j]&(1 << k)) { if (cascade[j]&(1 << k)) {
GET_VALIDATED_INDEX(res_setup->books[j][k], 8, vc->codebook_count) GET_VALIDATED_INDEX(res_setup->books[j][k], 8, vc->codebook_count)
AV_DEBUG(" %u class cascade depth %u book: %d\n", av_dlog(NULL, " %u class cascade depth %u book: %d\n",
j, k, res_setup->books[j][k]); j, k, res_setup->books[j][k]);
if (k>res_setup->maxpass) if (k>res_setup->maxpass)
res_setup->maxpass = k; res_setup->maxpass = k;
@ -727,7 +728,7 @@ static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc)
vc->mapping_count = get_bits(gb, 6)+1; vc->mapping_count = get_bits(gb, 6)+1;
vc->mappings = av_mallocz(vc->mapping_count * sizeof(*vc->mappings)); 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) { for (i = 0; i < vc->mapping_count; ++i) {
vorbis_mapping *mapping_setup = &vc->mappings[i]; vorbis_mapping *mapping_setup = &vc->mappings[i];
@ -756,8 +757,8 @@ static int vorbis_parse_setup_hdr_mappings(vorbis_context *vc)
mapping_setup->coupling_steps = 0; mapping_setup->coupling_steps = 0;
} }
AV_DEBUG(" %u mapping coupling steps: %d\n", av_dlog(NULL, " %u mapping coupling steps: %d\n",
i, mapping_setup->coupling_steps); i, mapping_setup->coupling_steps);
if (get_bits(gb, 2)) { if (get_bits(gb, 2)) {
av_log(vc->avccontext, AV_LOG_ERROR, "%u. mapping setup data invalid.\n", i); av_log(vc->avccontext, AV_LOG_ERROR, "%u. mapping setup data invalid.\n", i);
@ -776,10 +777,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_floor[j], 8, vc->floor_count)
GET_VALIDATED_INDEX(mapping_setup->submap_residue[j], 8, vc->residue_count) GET_VALIDATED_INDEX(mapping_setup->submap_residue[j], 8, vc->residue_count)
AV_DEBUG(" %u mapping %u submap : floor %d, residue %d\n", av_dlog(NULL, " %u mapping %u submap : floor %d, residue %d\n", i, j,
i, j, mapping_setup->submap_floor[j],
mapping_setup->submap_floor[j], mapping_setup->submap_residue[j]);
mapping_setup->submap_residue[j]);
} }
} }
return 0; return 0;
@ -816,8 +816,7 @@ static void create_map(vorbis_context *vc, unsigned floor_number)
#ifdef V_DEBUG #ifdef V_DEBUG
for (idx = 0; idx <= n; ++idx) { for (idx = 0; idx <= n; ++idx) {
AV_DEBUG("floor0 map: map at pos %d is %d\n", av_dlog(NULL, "floor0 map: map at pos %d is %d\n", idx, map[idx]);
idx, map[idx]);
} }
#endif #endif
} }
@ -830,7 +829,7 @@ static int vorbis_parse_setup_hdr_modes(vorbis_context *vc)
vc->mode_count = get_bits(gb, 6) + 1; vc->mode_count = get_bits(gb, 6) + 1;
vc->modes = av_mallocz(vc->mode_count * sizeof(*vc->modes)); 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) { for (i = 0; i < vc->mode_count; ++i) {
vorbis_mode *mode_setup = &vc->modes[i]; vorbis_mode *mode_setup = &vc->modes[i];
@ -840,9 +839,9 @@ static int vorbis_parse_setup_hdr_modes(vorbis_context *vc)
mode_setup->transformtype = get_bits(gb, 16); //FIXME check mode_setup->transformtype = get_bits(gb, 16); //FIXME check
GET_VALIDATED_INDEX(mode_setup->mapping, 8, vc->mapping_count); GET_VALIDATED_INDEX(mode_setup->mapping, 8, vc->mapping_count);
AV_DEBUG(" %u mode: blockflag %d, windowtype %d, transformtype %d, mapping %d\n", av_dlog(NULL, " %u mode: blockflag %d, windowtype %d, transformtype %d, mapping %d\n",
i, mode_setup->blockflag, mode_setup->windowtype, i, mode_setup->blockflag, mode_setup->windowtype,
mode_setup->transformtype, mode_setup->mapping); mode_setup->transformtype, mode_setup->mapping);
} }
return 0; return 0;
} }
@ -950,7 +949,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[0], bl0, 1, -vc->scale_bias);
ff_mdct_init(&vc->mdct[1], bl1, 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]); 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 +1057,7 @@ static int vorbis_floor0_decode(vorbis_context *vc,
"floor0 dec: booknumber too high!\n"); "floor0 dec: booknumber too high!\n");
book_idx = 0; 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]]; codebook = vc->codebooks[vf->book_list[book_idx]];
/* Invalid codebook! */ /* Invalid codebook! */
if (!codebook.codevectors) if (!codebook.codevectors)
@ -1067,13 +1066,13 @@ static int vorbis_floor0_decode(vorbis_context *vc,
while (lsp_len<vf->order) { while (lsp_len<vf->order) {
int vec_off; int vec_off;
AV_DEBUG("floor0 dec: book dimension: %d\n", codebook.dimensions); av_dlog(NULL, "floor0 dec: book dimension: %d\n", codebook.dimensions);
AV_DEBUG("floor0 dec: maximum depth: %d\n", codebook.maxdepth); av_dlog(NULL, "floor0 dec: maximum depth: %d\n", codebook.maxdepth);
/* read temp vector */ /* read temp vector */
vec_off = get_vlc2(&vc->gb, codebook.vlc.table, vec_off = get_vlc2(&vc->gb, codebook.vlc.table,
codebook.nb_bits, codebook.maxdepth) codebook.nb_bits, codebook.maxdepth)
* codebook.dimensions; * 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 */ /* copy each vector component and add last to it */
for (idx = 0; idx < codebook.dimensions; ++idx) for (idx = 0; idx < codebook.dimensions; ++idx)
lsp[lsp_len+idx] = codebook.codevectors[vec_off+idx] + last; lsp[lsp_len+idx] = codebook.codevectors[vec_off+idx] + last;
@ -1086,7 +1085,7 @@ static int vorbis_floor0_decode(vorbis_context *vc,
{ {
int idx; int idx;
for (idx = 0; idx < lsp_len; ++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 #endif
@ -1141,7 +1140,7 @@ static int vorbis_floor0_decode(vorbis_context *vc,
return 1; return 1;
} }
AV_DEBUG(" Floor0 decoded\n"); av_dlog(NULL, " Floor0 decoded\n");
return 0; return 0;
} }
@ -1168,7 +1167,7 @@ static int vorbis_floor1_decode(vorbis_context *vc,
floor1_Y[0] = get_bits(gb, ilog(range - 1)); floor1_Y[0] = get_bits(gb, ilog(range - 1));
floor1_Y[1] = 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; offset = 2;
for (i = 0; i < vf->partitions; ++i) { for (i = 0; i < vf->partitions; ++i) {
@ -1178,7 +1177,7 @@ static int vorbis_floor1_decode(vorbis_context *vc,
csub = (1 << cbits) - 1; csub = (1 << cbits) - 1;
cval = 0; 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 if (cbits) // this reads all subclasses for this partition's class
cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[class]].vlc.table, cval = get_vlc2(gb, vc->codebooks[vf->class_masterbook[class]].vlc.table,
@ -1187,8 +1186,8 @@ static int vorbis_floor1_decode(vorbis_context *vc,
for (j = 0; j < cdim; ++j) { for (j = 0; j < cdim; ++j) {
book = vf->subclass_books[class][cval & csub]; book = vf->subclass_books[class][cval & csub];
AV_DEBUG("book %d Cbits %u cval %u bits:%d\n", av_dlog(NULL, "book %d Cbits %u cval %u bits:%d\n",
book, cbits, cval, get_bits_count(gb)); book, cbits, cval, get_bits_count(gb));
cval = cval >> cbits; cval = cval >> cbits;
if (book > -1) { if (book > -1) {
@ -1198,7 +1197,8 @@ static int vorbis_floor1_decode(vorbis_context *vc,
floor1_Y[offset+j] = 0; 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; offset+=cdim;
} }
@ -1256,15 +1256,15 @@ static int vorbis_floor1_decode(vorbis_context *vc,
floor1_Y_final[i] = predicted; floor1_Y_final[i] = predicted;
} }
AV_DEBUG(" Decoded floor(%d) = %u / val %u\n", av_dlog(NULL, " Decoded floor(%d) = %u / val %u\n",
vf->list[i].x, floor1_Y_final[i], val); vf->list[i].x, floor1_Y_final[i], val);
} }
// Curve synth - connect the calculated dots and convert from dB scale FIXME optimize ? // 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); 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; return 0;
} }
@ -1295,7 +1295,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
ch_used = ch; 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? for (pass = 0; pass <= vr->maxpass; ++pass) { // FIXME OPTIMIZE?
uint16_t voffset, partition_count, j_times_ptns_to_read; uint16_t voffset, partition_count, j_times_ptns_to_read;
@ -1309,7 +1309,7 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
unsigned temp = get_vlc2(gb, vc->codebooks[vr->classbook].vlc.table, unsigned temp = get_vlc2(gb, vc->codebooks[vr->classbook].vlc.table,
vc->codebooks[vr->classbook].nb_bits, 3); 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[] assert(vr->classifications > 1 && temp <= 65536); //needed for inverse[]
for (i = 0; i < c_p_c; ++i) { for (i = 0; i < c_p_c; ++i) {
@ -1354,7 +1354,8 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
for (l = 0; l < dim; ++l, ++voffs) { for (l = 0; l < dim; ++l, ++voffs) {
vec[voffs]+=codebook.codevectors[coffs+l]; // FPMATH 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 } else if (vr_type == 2 && ch == 2 && (voffset & 1) == 0 && (dim & 1) == 0) { // most frequent case optimized
@ -1381,7 +1382,10 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
vec[voffs ] += codebook.codevectors[coffs + l ]; // FPMATH vec[voffs ] += codebook.codevectors[coffs + l ]; // FPMATH
vec[voffs + vlen] += codebook.codevectors[coffs + l + 1]; // 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 +1397,10 @@ static av_always_inline int vorbis_residue_decode_internal(vorbis_context *vc,
for (l = 0; l < dim; ++l, ++voffs) { 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 % 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 +1488,8 @@ static int vorbis_parse_audio_packet(vorbis_context *vc)
vc->mode_number = mode_number; vc->mode_number = mode_number;
mapping = &vc->mappings[vc->modes[mode_number].mapping]; mapping = &vc->mappings[vc->modes[mode_number].mapping];
AV_DEBUG(" Mode number: %u , mapping: %d , blocktype %d\n", mode_number, av_dlog(NULL, " Mode number: %u , mapping: %d , blocktype %d\n", mode_number,
vc->modes[mode_number].mapping, vc->modes[mode_number].blockflag); vc->modes[mode_number].mapping, vc->modes[mode_number].blockflag);
blockflag = vc->modes[mode_number].blockflag; blockflag = vc->modes[mode_number].blockflag;
blocksize = vc->blocksize[blockflag]; blocksize = vc->blocksize[blockflag];
@ -1611,7 +1618,7 @@ static int vorbis_decode_frame(AVCodecContext *avccontext,
if (!buf_size) if (!buf_size)
return 0; 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); init_get_bits(gb, buf, buf_size*8);
@ -1628,7 +1635,8 @@ static int vorbis_decode_frame(AVCodecContext *avccontext,
return buf_size ; 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) { if (vc->audio_channels > 8) {
for (i = 0; i < vc->audio_channels; i++) for (i = 0; i < vc->audio_channels; i++)

View File

@ -90,14 +90,6 @@
#define CPLZ_TAG MKBETAG('C', 'P', 'L', 'Z') #define CPLZ_TAG MKBETAG('C', 'P', 'L', 'Z')
#define VPTZ_TAG MKBETAG('V', 'P', 'T', '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 { typedef struct VqaContext {
AVCodecContext *avctx; AVCodecContext *avctx;
@ -212,7 +204,7 @@ static void decode_format80(const unsigned char *src, int src_size,
while (src_index < 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 */ /* 0x80 means that frame is finished */
if (src[src_index] == 0x80) if (src[src_index] == 0x80)
@ -231,7 +223,7 @@ static void decode_format80(const unsigned char *src, int src_size,
src_index += 2; src_index += 2;
src_pos = AV_RL16(&src[src_index]); src_pos = AV_RL16(&src[src_index]);
src_index += 2; 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(); CHECK_COUNT();
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
dest[dest_index + i] = dest[src_pos + i]; dest[dest_index + i] = dest[src_pos + i];
@ -243,7 +235,7 @@ static void decode_format80(const unsigned char *src, int src_size,
count = AV_RL16(&src[src_index]); count = AV_RL16(&src[src_index]);
src_index += 2; src_index += 2;
color = src[src_index++]; 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(); CHECK_COUNT();
memset(&dest[dest_index], color, count); memset(&dest[dest_index], color, count);
dest_index += count; dest_index += count;
@ -253,7 +245,7 @@ static void decode_format80(const unsigned char *src, int src_size,
count = (src[src_index++] & 0x3F) + 3; count = (src[src_index++] & 0x3F) + 3;
src_pos = AV_RL16(&src[src_index]); src_pos = AV_RL16(&src[src_index]);
src_index += 2; 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(); CHECK_COUNT();
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
dest[dest_index + i] = dest[src_pos + i]; dest[dest_index + i] = dest[src_pos + i];
@ -262,7 +254,7 @@ static void decode_format80(const unsigned char *src, int src_size,
} else if (src[src_index] > 0x80) { } else if (src[src_index] > 0x80) {
count = src[src_index++] & 0x3F; 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(); CHECK_COUNT();
memcpy(&dest[dest_index], &src[src_index], count); memcpy(&dest[dest_index], &src[src_index], count);
src_index += count; src_index += count;
@ -273,7 +265,7 @@ static void decode_format80(const unsigned char *src, int src_size,
count = ((src[src_index] & 0x70) >> 4) + 3; count = ((src[src_index] & 0x70) >> 4) + 3;
src_pos = AV_RB16(&src[src_index]) & 0x0FFF; src_pos = AV_RB16(&src[src_index]) & 0x0FFF;
src_index += 2; 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(); CHECK_COUNT();
for (i = 0; i < count; i++) for (i = 0; i < count; i++)
dest[dest_index + i] = dest[dest_index - src_pos + i]; dest[dest_index + i] = dest[dest_index - src_pos + i];

View File

@ -35,17 +35,6 @@
#include "libavutil/intreadwrite.h" #include "libavutil/intreadwrite.h"
#include "avformat.h" #include "avformat.h"
/* debugging support: #define DEBUG_IPMOVIE as non-zero to see extremely
* verbose information about the demux process */
#define DEBUG_IPMOVIE 0
#if DEBUG_IPMOVIE
#undef printf
#define debug_ipmovie printf
#else
static inline void debug_ipmovie(const char *format, ...) { }
#endif
#define CHUNK_PREAMBLE_SIZE 4 #define CHUNK_PREAMBLE_SIZE 4
#define OPCODE_PREAMBLE_SIZE 4 #define OPCODE_PREAMBLE_SIZE 4
@ -150,8 +139,8 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
s->audio_frame_count += s->audio_frame_count +=
(s->audio_chunk_size - 6) / s->audio_channels; (s->audio_chunk_size - 6) / s->audio_channels;
debug_ipmovie("sending audio frame with pts %"PRId64" (%d audio frames)\n", av_dlog(NULL, "sending audio frame with pts %"PRId64" (%d audio frames)\n",
pkt->pts, s->audio_frame_count); pkt->pts, s->audio_frame_count);
chunk_type = CHUNK_VIDEO; chunk_type = CHUNK_VIDEO;
@ -195,8 +184,7 @@ static int load_ipmovie_packet(IPMVEContext *s, AVIOContext *pb,
pkt->stream_index = s->video_stream_index; pkt->stream_index = s->video_stream_index;
pkt->pts = s->video_pts; pkt->pts = s->video_pts;
debug_ipmovie("sending video frame with pts %"PRId64"\n", av_dlog(NULL, "sending video frame with pts %"PRId64"\n", pkt->pts);
pkt->pts);
s->video_pts += s->frame_pts_inc; s->video_pts += s->frame_pts_inc;
@ -244,36 +232,36 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
chunk_size = AV_RL16(&chunk_preamble[0]); chunk_size = AV_RL16(&chunk_preamble[0]);
chunk_type = AV_RL16(&chunk_preamble[2]); chunk_type = AV_RL16(&chunk_preamble[2]);
debug_ipmovie("chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size); av_dlog(NULL, "chunk type 0x%04X, 0x%04X bytes: ", chunk_type, chunk_size);
switch (chunk_type) { switch (chunk_type) {
case CHUNK_INIT_AUDIO: case CHUNK_INIT_AUDIO:
debug_ipmovie("initialize audio\n"); av_dlog(NULL, "initialize audio\n");
break; break;
case CHUNK_AUDIO_ONLY: case CHUNK_AUDIO_ONLY:
debug_ipmovie("audio only\n"); av_dlog(NULL, "audio only\n");
break; break;
case CHUNK_INIT_VIDEO: case CHUNK_INIT_VIDEO:
debug_ipmovie("initialize video\n"); av_dlog(NULL, "initialize video\n");
break; break;
case CHUNK_VIDEO: case CHUNK_VIDEO:
debug_ipmovie("video (and audio)\n"); av_dlog(NULL, "video (and audio)\n");
break; break;
case CHUNK_SHUTDOWN: case CHUNK_SHUTDOWN:
debug_ipmovie("shutdown\n"); av_dlog(NULL, "shutdown\n");
break; break;
case CHUNK_END: case CHUNK_END:
debug_ipmovie("end\n"); av_dlog(NULL, "end\n");
break; break;
default: default:
debug_ipmovie("invalid chunk\n"); av_dlog(NULL, "invalid chunk\n");
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
@ -299,29 +287,29 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
chunk_size -= OPCODE_PREAMBLE_SIZE; chunk_size -= OPCODE_PREAMBLE_SIZE;
chunk_size -= opcode_size; chunk_size -= opcode_size;
if (chunk_size < 0) { if (chunk_size < 0) {
debug_ipmovie("chunk_size countdown just went negative\n"); av_dlog(NULL, "chunk_size countdown just went negative\n");
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
} }
debug_ipmovie(" opcode type %02X, version %d, 0x%04X bytes: ", av_dlog(NULL, " opcode type %02X, version %d, 0x%04X bytes: ",
opcode_type, opcode_version, opcode_size); opcode_type, opcode_version, opcode_size);
switch (opcode_type) { switch (opcode_type) {
case OPCODE_END_OF_STREAM: case OPCODE_END_OF_STREAM:
debug_ipmovie("end of stream\n"); av_dlog(NULL, "end of stream\n");
avio_skip(pb, opcode_size); avio_skip(pb, opcode_size);
break; break;
case OPCODE_END_OF_CHUNK: case OPCODE_END_OF_CHUNK:
debug_ipmovie("end of chunk\n"); av_dlog(NULL, "end of chunk\n");
avio_skip(pb, opcode_size); avio_skip(pb, opcode_size);
break; break;
case OPCODE_CREATE_TIMER: case OPCODE_CREATE_TIMER:
debug_ipmovie("create timer\n"); av_dlog(NULL, "create timer\n");
if ((opcode_version > 0) || (opcode_size > 6)) { if ((opcode_version > 0) || (opcode_size > 6)) {
debug_ipmovie("bad create_timer opcode\n"); av_dlog(NULL, "bad create_timer opcode\n");
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
} }
@ -331,14 +319,15 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
break; break;
} }
s->frame_pts_inc = ((uint64_t)AV_RL32(&scratch[0])) * AV_RL16(&scratch[4]); s->frame_pts_inc = ((uint64_t)AV_RL32(&scratch[0])) * AV_RL16(&scratch[4]);
debug_ipmovie(" %.2f frames/second (timer div = %d, subdiv = %d)\n", av_dlog(NULL, " %.2f frames/second (timer div = %d, subdiv = %d)\n",
1000000.0/s->frame_pts_inc, AV_RL32(&scratch[0]), AV_RL16(&scratch[4])); 1000000.0 / s->frame_pts_inc, AV_RL32(&scratch[0]),
AV_RL16(&scratch[4]));
break; break;
case OPCODE_INIT_AUDIO_BUFFERS: case OPCODE_INIT_AUDIO_BUFFERS:
debug_ipmovie("initialize audio buffers\n"); av_dlog(NULL, "initialize audio buffers\n");
if ((opcode_version > 1) || (opcode_size > 10)) { if ((opcode_version > 1) || (opcode_size > 10)) {
debug_ipmovie("bad init_audio_buffers opcode\n"); av_dlog(NULL, "bad init_audio_buffers opcode\n");
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
} }
@ -360,23 +349,22 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
s->audio_type = CODEC_ID_PCM_S16LE; s->audio_type = CODEC_ID_PCM_S16LE;
else else
s->audio_type = CODEC_ID_PCM_U8; s->audio_type = CODEC_ID_PCM_U8;
debug_ipmovie("audio: %d bits, %d Hz, %s, %s format\n", av_dlog(NULL, "audio: %d bits, %d Hz, %s, %s format\n",
s->audio_bits, s->audio_bits, s->audio_sample_rate,
s->audio_sample_rate, (s->audio_channels == 2) ? "stereo" : "mono",
(s->audio_channels == 2) ? "stereo" : "mono", (s->audio_type == CODEC_ID_INTERPLAY_DPCM) ?
(s->audio_type == CODEC_ID_INTERPLAY_DPCM) ? "Interplay audio" : "PCM");
"Interplay audio" : "PCM");
break; break;
case OPCODE_START_STOP_AUDIO: case OPCODE_START_STOP_AUDIO:
debug_ipmovie("start/stop audio\n"); av_dlog(NULL, "start/stop audio\n");
avio_skip(pb, opcode_size); avio_skip(pb, opcode_size);
break; break;
case OPCODE_INIT_VIDEO_BUFFERS: case OPCODE_INIT_VIDEO_BUFFERS:
debug_ipmovie("initialize video buffers\n"); av_dlog(NULL, "initialize video buffers\n");
if ((opcode_version > 2) || (opcode_size > 8)) { if ((opcode_version > 2) || (opcode_size > 8)) {
debug_ipmovie("bad init_video_buffers opcode\n"); av_dlog(NULL, "bad init_video_buffers opcode\n");
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
} }
@ -392,8 +380,8 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
} else { } else {
s->video_bpp = 16; s->video_bpp = 16;
} }
debug_ipmovie("video resolution: %d x %d\n", av_dlog(NULL, "video resolution: %d x %d\n",
s->video_width, s->video_height); s->video_width, s->video_height);
break; break;
case OPCODE_UNKNOWN_06: case OPCODE_UNKNOWN_06:
@ -403,17 +391,17 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
case OPCODE_UNKNOWN_13: case OPCODE_UNKNOWN_13:
case OPCODE_UNKNOWN_14: case OPCODE_UNKNOWN_14:
case OPCODE_UNKNOWN_15: case OPCODE_UNKNOWN_15:
debug_ipmovie("unknown (but documented) opcode %02X\n", opcode_type); av_dlog(NULL, "unknown (but documented) opcode %02X\n", opcode_type);
avio_skip(pb, opcode_size); avio_skip(pb, opcode_size);
break; break;
case OPCODE_SEND_BUFFER: case OPCODE_SEND_BUFFER:
debug_ipmovie("send buffer\n"); av_dlog(NULL, "send buffer\n");
avio_skip(pb, opcode_size); avio_skip(pb, opcode_size);
break; break;
case OPCODE_AUDIO_FRAME: case OPCODE_AUDIO_FRAME:
debug_ipmovie("audio frame\n"); av_dlog(NULL, "audio frame\n");
/* log position and move on for now */ /* log position and move on for now */
s->audio_chunk_offset = avio_tell(pb); s->audio_chunk_offset = avio_tell(pb);
@ -422,26 +410,26 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
break; break;
case OPCODE_SILENCE_FRAME: case OPCODE_SILENCE_FRAME:
debug_ipmovie("silence frame\n"); av_dlog(NULL, "silence frame\n");
avio_skip(pb, opcode_size); avio_skip(pb, opcode_size);
break; break;
case OPCODE_INIT_VIDEO_MODE: case OPCODE_INIT_VIDEO_MODE:
debug_ipmovie("initialize video mode\n"); av_dlog(NULL, "initialize video mode\n");
avio_skip(pb, opcode_size); avio_skip(pb, opcode_size);
break; break;
case OPCODE_CREATE_GRADIENT: case OPCODE_CREATE_GRADIENT:
debug_ipmovie("create gradient\n"); av_dlog(NULL, "create gradient\n");
avio_skip(pb, opcode_size); avio_skip(pb, opcode_size);
break; break;
case OPCODE_SET_PALETTE: case OPCODE_SET_PALETTE:
debug_ipmovie("set palette\n"); av_dlog(NULL, "set palette\n");
/* check for the logical maximum palette size /* check for the logical maximum palette size
* (3 * 256 + 4 bytes) */ * (3 * 256 + 4 bytes) */
if (opcode_size > 0x304) { if (opcode_size > 0x304) {
debug_ipmovie("demux_ipmovie: set_palette opcode too large\n"); av_dlog(NULL, "demux_ipmovie: set_palette opcode too large\n");
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
} }
@ -455,7 +443,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
last_color = first_color + AV_RL16(&scratch[2]) - 1; last_color = first_color + AV_RL16(&scratch[2]) - 1;
/* sanity check (since they are 16 bit values) */ /* sanity check (since they are 16 bit values) */
if ((first_color > 0xFF) || (last_color > 0xFF)) { if ((first_color > 0xFF) || (last_color > 0xFF)) {
debug_ipmovie("demux_ipmovie: set_palette indexes out of range (%d -> %d)\n", av_dlog(NULL, "demux_ipmovie: set_palette indexes out of range (%d -> %d)\n",
first_color, last_color); first_color, last_color);
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;
@ -473,12 +461,12 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
break; break;
case OPCODE_SET_PALETTE_COMPRESSED: case OPCODE_SET_PALETTE_COMPRESSED:
debug_ipmovie("set palette compressed\n"); av_dlog(NULL, "set palette compressed\n");
avio_skip(pb, opcode_size); avio_skip(pb, opcode_size);
break; break;
case OPCODE_SET_DECODING_MAP: case OPCODE_SET_DECODING_MAP:
debug_ipmovie("set decoding map\n"); av_dlog(NULL, "set decoding map\n");
/* log position and move on for now */ /* log position and move on for now */
s->decode_map_chunk_offset = avio_tell(pb); s->decode_map_chunk_offset = avio_tell(pb);
@ -487,7 +475,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
break; break;
case OPCODE_VIDEO_DATA: case OPCODE_VIDEO_DATA:
debug_ipmovie("set video data\n"); av_dlog(NULL, "set video data\n");
/* log position and move on for now */ /* log position and move on for now */
s->video_chunk_offset = avio_tell(pb); s->video_chunk_offset = avio_tell(pb);
@ -496,7 +484,7 @@ static int process_ipmovie_chunk(IPMVEContext *s, AVIOContext *pb,
break; break;
default: default:
debug_ipmovie("*** unknown opcode type\n"); av_dlog(NULL, "*** unknown opcode type\n");
chunk_type = CHUNK_BAD; chunk_type = CHUNK_BAD;
break; break;