Start of converting printf (etc) to the new message functions.

--HG--
extra : convert_revision : svn%3Aeff31bef-be4a-0410-a8fe-e47997df2690/trunk%40130
issue20
tibs 2009-02-23 20:09:45 +00:00
rodzic 0763ebb39c
commit ef5a9ea9f9
6 zmienionych plików z 185 dodań i 185 usunięć

31
ac3.c
Wyświetl plik

@ -33,6 +33,7 @@
#include <string.h>
#include "compat.h"
#include "printing_fns.h"
#include "misc_fns.h"
#include "ac3_fns.h"
@ -91,18 +92,18 @@ int read_next_ac3_frame(int file,
return EOF;
else if (err)
{
fprintf(stderr, "### Error reading syncinfo from AC3 file\n");
fprintf(stderr, " (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
fprint_err("### Error reading syncinfo from AC3 file\n"
" (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
return 1;
}
if (sync_info[0] != 0x0b || sync_info[1] != 0x77)
{
fprintf(stderr, "### AC3 frame does not start with 0x0b77"
" syncword - lost synchronisation?\n"
" Found 0x%02x%02x instead of 0x0b77\n",
(unsigned)sync_info[0], (unsigned)sync_info[1]);
fprintf(stderr, " (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
fprint_err("### AC3 frame does not start with 0x0b77"
" syncword - lost synchronisation?\n"
" Found 0x%02x%02x instead of 0x0b77\n",
(unsigned)sync_info[0], (unsigned)sync_info[1]);
fprint_err(" (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
return 1;
}
@ -110,17 +111,17 @@ int read_next_ac3_frame(int file,
if (fscod == 3)
{
// Bad sample rate code
fprintf(stderr, "### Bad sample rate code in AC3 syncinfo\n");
fprintf(stderr, " (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
fprint_err("### Bad sample rate code in AC3 syncinfo\n"
" (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
return 1;
}
frmsizecod = sync_info[4] & 0x3f;
if (frmsizecod > 37)
{
fprintf(stderr, "### Bad frame size code %d in AC3 syncinfo\n",
frmsizecod);
fprintf(stderr, " (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
fprint_err("### Bad frame size code %d in AC3 syncinfo\n",
frmsizecod);
fprint_err(" (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
return 1;
}
@ -132,7 +133,7 @@ int read_next_ac3_frame(int file,
data = malloc(frame_length);
if (data == NULL)
{
fprintf(stderr, "### Unable to extend data buffer for AC3 frame\n");
print_err("### Unable to extend data buffer for AC3 frame\n");
return 1;
}
for (i = 0; i < SYNCINFO_SIZE; i++)
@ -143,9 +144,9 @@ int read_next_ac3_frame(int file,
if (err)
{
if (err == EOF)
fprintf(stderr, "### Unexpected EOF reading rest of AC3 frame\n");
print_err("### Unexpected EOF reading rest of AC3 frame\n");
else
fprintf(stderr, "### Error reading rest of AC3 frame\n");
print_err("### Error reading rest of AC3 frame\n");
free(data);
return 1;
}

Wyświetl plik

@ -30,6 +30,7 @@
#include <stdlib.h>
#include "compat.h"
#include "printing_fns.h"
#include "es_fns.h"
#include "ts_fns.h"
#include "nalunit_fns.h"
@ -52,7 +53,7 @@ static inline int build_access_unit(access_unit_p *acc_unit,
access_unit_p new = malloc(SIZEOF_ACCESS_UNIT);
if (new == NULL)
{
fprintf(stderr,"### Unable to allocate access unit datastructure\n");
print_err("### Unable to allocate access unit datastructure\n");
return 1;
}
@ -134,7 +135,7 @@ extern void report_access_unit(FILE *stream,
else
{
fprintf(stream," %c",((access_unit->primary_start == nal)?'*':' '));
report_nal(stdout,nal);
report_nal(TRUE,nal);
}
}
}
@ -172,8 +173,7 @@ extern int get_access_unit_bounds(access_unit_p access_unit,
int ii;
if (access_unit->primary_start == NULL)
{
fprintf(stderr,
"### Cannot determine bounds of an access unit with no content\n");
print_err("### Cannot determine bounds of an access unit with no content\n");
return 1;
}
@ -315,8 +315,8 @@ static int access_unit_append(access_unit_p access_unit,
if (starts_primary && access_unit->started_primary_picture)
{
// Our caller should have started a new access unit instead
fprintf(stderr,"### Already had a start of primary picture in access"
" unit %d\n",access_unit->index);
fprint_err("### Already had a start of primary picture in access"
" unit %d\n",access_unit->index);
return 1;
}
@ -337,8 +337,8 @@ static int access_unit_append(access_unit_p access_unit,
pending->array[ii]);
if (err)
{
fprintf(stderr,"### Error extending access unit %d\n",
access_unit->index);
fprint_err("### Error extending access unit %d\n",
access_unit->index);
return err;
}
}
@ -349,8 +349,8 @@ static int access_unit_append(access_unit_p access_unit,
err = append_to_nal_unit_list(access_unit->nal_units,nal);
if (err)
{
fprintf(stderr,"### Error extending access unit %d\n",
access_unit->index);
fprint_err("### Error extending access unit %d\n",
access_unit->index);
return err;
}
}
@ -374,7 +374,7 @@ static int merge_access_unit_nals(access_unit_p access_unit1,
(*access_unit2)->nal_units->array[ii]);
if (err)
{
fprintf(stderr,"### Error merging two access units\n");
print_err("### Error merging two access units\n");
return err;
}
}
@ -419,8 +419,8 @@ extern int write_access_unit_as_ES(access_unit_p access_unit,
err = write_ES_unit(output,&(access_unit->nal_units->array[ii]->unit));
if (err)
{
fprintf(stderr,"### Error writing NAL unit ");
report_nal(stderr,access_unit->nal_units->array[ii]);
print_err("### Error writing NAL unit ");
report_nal(FALSE,access_unit->nal_units->array[ii]);
return err;
}
}
@ -430,8 +430,8 @@ extern int write_access_unit_as_ES(access_unit_p access_unit,
err = write_ES_unit(output,&(context->end_of_sequence->unit));
if (err)
{
fprintf(stderr,"### Error writing end of sequence NAL unit ");
report_nal(stderr,context->end_of_sequence);
print_err("### Error writing end of sequence NAL unit ");
report_nal(FALSE,context->end_of_sequence);
return err;
}
free_nal_unit(&context->end_of_sequence);
@ -442,8 +442,8 @@ extern int write_access_unit_as_ES(access_unit_p access_unit,
err = write_ES_unit(output,&(context->end_of_stream->unit));
if (err)
{
fprintf(stderr,"### Error writing end of stream NAL unit ");
report_nal(stderr,context->end_of_sequence);
print_err("### Error writing end of stream NAL unit ");
report_nal(FALSE,context->end_of_sequence);
return err;
}
free_nal_unit(&context->end_of_stream);
@ -478,8 +478,8 @@ static int write_access_unit_trailer_as_TS(access_unit_context_p context,
video_pid,DEFAULT_VIDEO_STREAM_ID);
if (err)
{
fprintf(stderr,"### Error writing end of sequence NAL unit ");
report_nal(stderr,nal);
print_err("### Error writing end of sequence NAL unit ");
report_nal(FALSE,nal);
return err;
}
free_nal_unit(&context->end_of_sequence);
@ -492,8 +492,8 @@ static int write_access_unit_trailer_as_TS(access_unit_context_p context,
video_pid,DEFAULT_VIDEO_STREAM_ID);
if (err)
{
fprintf(stderr,"### Error writing end of stream NAL unit ");
report_nal(stderr,nal);
print_err("### Error writing end of stream NAL unit ");
report_nal(FALSE,nal);
return err;
}
free_nal_unit(&context->end_of_stream);
@ -532,8 +532,8 @@ extern int write_access_unit_as_TS(access_unit_p access_unit,
video_pid,DEFAULT_VIDEO_STREAM_ID);
if (err)
{
fprintf(stderr,"### Error writing NAL unit ");
report_nal(stderr,nal);
print_err("### Error writing NAL unit ");
report_nal(FALSE,nal);
return err;
}
}
@ -593,8 +593,8 @@ extern int write_access_unit_as_TS_with_pts_dts(access_unit_p access_un
video_pid,DEFAULT_VIDEO_STREAM_ID);
if (err)
{
fprintf(stderr,"### Error writing NAL unit ");
report_nal(stderr,nal);
print_err("### Error writing NAL unit ");
report_nal(FALSE,nal);
return err;
}
}
@ -645,8 +645,8 @@ extern int write_access_unit_as_TS_with_PCR(access_unit_p access_unit,
video_pid,DEFAULT_VIDEO_STREAM_ID);
if (err)
{
fprintf(stderr,"### Error writing NAL unit ");
report_nal(stderr,nal);
print_err("### Error writing NAL unit ");
report_nal(FALSE,nal);
return err;
}
}
@ -676,17 +676,17 @@ static inline int end_access_unit(access_unit_context_p context,
if (context->pending_nal)
{
printf("... pending: ");
report_nal(stdout,context->pending_nal);
report_nal(TRUE,context->pending_nal);
}
if (context->end_of_sequence)
{
printf("--> EndOfSequence ");
report_nal(stdout,context->end_of_sequence);
report_nal(TRUE,context->end_of_sequence);
}
if (context->end_of_stream)
{
printf("--> EndOfStream ");
report_nal(stdout,context->end_of_stream);
report_nal(TRUE,context->end_of_stream);
}
}
return 0;
@ -704,8 +704,7 @@ extern int build_access_unit_context(ES_p es,
access_unit_context_p new = malloc(SIZEOF_ACCESS_UNIT_CONTEXT);
if (new == NULL)
{
fprintf(stderr,
"### Unable to allocate access unit context datastructure\n");
print_err("### Unable to allocate access unit context datastructure\n");
return 1;
}
@ -720,14 +719,14 @@ extern int build_access_unit_context(ES_p es,
err = build_nal_unit_context(es,&new->nac);
if (err)
{
fprintf(stderr,"### Error building access unit context datastructure\n");
print_err("### Error building access unit context datastructure\n");
free(new);
return err;
}
err = build_nal_unit_list(&new->pending_list);
if (err)
{
fprintf(stderr,"### Error building access unit context datastructure\n");
print_err("### Error building access unit context datastructure\n");
free_nal_unit_context(&new->nac);
free(new);
return err;
@ -850,8 +849,7 @@ static int remember_earlier_primary_start(access_unit_context_p context,
int err = build_nal_unit(&tgt);
if (err)
{
fprintf(stderr,
"### Error building NAL unit for 'earlier primary start'\n");
print_err("### Error building NAL unit for 'earlier primary start'\n");
free(tgt);
return err;
}
@ -894,16 +892,16 @@ static int maybe_remember_access_unit(reverse_data_p reverse_data,
int err = get_access_unit_bounds(access_unit,&start_posn,&num_bytes);
if (err)
{
fprintf(stderr,"### Error working out position/size of access unit %d"
" for reversing\n",access_unit->index);
fprint_err("### Error working out position/size of access unit %d"
" for reversing\n",access_unit->index);
return 1;
}
err = remember_reverse_h264_data(reverse_data,access_unit->index,
start_posn,num_bytes);
if (err)
{
fprintf(stderr,"### Error remembering access unit %d for reversing\n",
access_unit->index);
fprint_err("### Error remembering access unit %d for reversing\n",
access_unit->index);
return 1;
}
if (verbose) printf("REMEMBER IDR %5d at " OFFSET_T_FORMAT_08
@ -993,13 +991,13 @@ extern int get_next_access_unit(access_unit_context_p context,
// unit).
// Clearly, option (a) is the easiest to try, so let's see how that
// works for now...
fprintf(stderr,"!!! Ignoring broken NAL unit\n");
print_err("!!! Ignoring broken NAL unit\n");
access_unit->ignored_broken_NAL_units ++;
continue;
}
else if (err)
{
fprintf(stderr,"### Error retrieving next NAL\n");
print_err("### Error retrieving next NAL\n");
goto give_up;
}
@ -1048,10 +1046,10 @@ extern int get_next_access_unit(access_unit_context_p context,
// access unit. So what should we do? Ignore it?
if (!quiet)
{
fprintf(stderr,"!!! Ignoring VCL NAL that cannot start a picture:\n");
fprintf(stderr," ");
report_nal(stderr,nal);
fprintf(stderr,"\n");
print_err("!!! Ignoring VCL NAL that cannot start a picture:\n");
print_err(" ");
report_nal(FALSE,nal);
print_err("\n");
}
free_nal_unit(&nal);
}
@ -1084,15 +1082,15 @@ extern int get_next_access_unit(access_unit_context_p context,
if (context->pending_list->length > 0 ||
access_unit->nal_units->length > 0)
{
fprintf(stderr,"!!! Ignoring incomplete access unit:\n");
print_err("!!! Ignoring incomplete access unit:\n");
if (access_unit->nal_units->length > 0)
{
report_nal_unit_list(stderr," ",access_unit->nal_units);
report_nal_unit_list(FALSE," ",access_unit->nal_units);
reset_nal_unit_list(access_unit->nal_units,TRUE);
}
if (context->pending_list->length > 0)
{
report_nal_unit_list(stderr," ",context->pending_list);
report_nal_unit_list(FALSE," ",context->pending_list);
reset_nal_unit_list(context->pending_list,TRUE);
}
}
@ -1141,9 +1139,9 @@ extern int get_next_access_unit(access_unit_context_p context,
{
if (context->pending_list->length > 0)
{
fprintf(stderr,"!!! Ignoring items after last VCL NAL and"
" before End of Sequence:\n");
report_nal_unit_list(stderr," ",context->pending_list);
print_err("!!! Ignoring items after last VCL NAL and"
" before End of Sequence:\n");
report_nal_unit_list(FALSE," ",context->pending_list);
reset_nal_unit_list(context->pending_list,TRUE);
}
// And remember this as the End of Sequence marker
@ -1154,9 +1152,9 @@ extern int get_next_access_unit(access_unit_context_p context,
{
if (context->pending_list->length > 0)
{
fprintf(stderr,"!!! Ignoring items after last VCL NAL and"
" before End of Stream:\n");
report_nal_unit_list(stderr," ",context->pending_list);
print_err("!!! Ignoring items after last VCL NAL and"
" before End of Stream:\n");
report_nal_unit_list(FALSE," ",context->pending_list);
reset_nal_unit_list(context->pending_list,TRUE);
}
// And remember this as the End of Stream marker
@ -1280,14 +1278,14 @@ static int get_next_field_of_pair(access_unit_context_p context,
if (err)
{
if (err != EOF)
fprintf(stderr,"### Trying to read second field\n");
print_err("### Trying to read second field\n");
return err;
}
if (second->field_pic_flag == 0)
{
if (!quiet)
fprintf(stderr,"!!! Field followed by a frame - ignoring the field\n");
print_err("!!! Field followed by a frame - ignoring the field\n");
free_access_unit(access_unit);
*access_unit = second;
// and pretend to success
@ -1309,10 +1307,10 @@ static int get_next_field_of_pair(access_unit_context_p context,
else if (first_time)
{
if (!quiet)
fprintf(stderr,"!!! Field with frame number %d (%x) followed by"
" field with frame number %d (%x) - ignoring first field\n",
(*access_unit)->frame_num,(*access_unit)->frame_num,
second->frame_num,second->frame_num);
fprint_err("!!! Field with frame number %d (%x) followed by"
" field with frame number %d (%x) - ignoring first field\n",
(*access_unit)->frame_num,(*access_unit)->frame_num,
second->frame_num,second->frame_num);
// Try again
free_access_unit(access_unit);
@ -1322,8 +1320,8 @@ static int get_next_field_of_pair(access_unit_context_p context,
}
else
{
fprintf(stderr,"### Adjacent fields do not share frame numbers"
" - unable to match fields up\n");
print_err("### Adjacent fields do not share frame numbers"
" - unable to match fields up\n");
return 1;
}
return 0;

201
nalunit.c
Wyświetl plik

@ -38,6 +38,7 @@
#endif // _WIN32
#include "compat.h"
#include "printing_fns.h"
#include "es_fns.h"
#include "ts_fns.h"
#include "bitdata_fns.h"
@ -73,7 +74,7 @@ extern int build_nal_unit_context(ES_p es,
nal_unit_context_p new = malloc(SIZEOF_NAL_UNIT_CONTEXT);
if (new == NULL)
{
fprintf(stderr,"### Unable to allocate NAL unit context datastructure\n");
fprint_err("### Unable to allocate NAL unit context datastructure\n");
return 1;
}
new->es = es;
@ -149,14 +150,14 @@ extern int build_nal_unit(nal_unit_p *nal)
nal_unit_p new = malloc(SIZEOF_NAL_UNIT);
if (new == NULL)
{
fprintf(stderr,"### Unable to allocate NAL unit datastructure\n");
fprint_err("### Unable to allocate NAL unit datastructure\n");
return 1;
}
err = setup_ES_unit(&(new->unit));
if (err)
{
fprintf(stderr,"### Unable to allocate NAL unit data buffer\n");
fprint_err("### Unable to allocate NAL unit data buffer\n");
free(new);
return 1;
}
@ -247,7 +248,7 @@ static int remove_emulation_prevention(byte data[],
tgt = malloc(data_len);
if (tgt == NULL)
{
fprintf(stderr,"### Cannot malloc RBSP target array\n");
fprint_err("### Cannot malloc RBSP target array\n");
return 1;
}
@ -290,7 +291,7 @@ static inline int prepare_rbsp(nal_unit_p nal)
&(nal->rbsp),&(nal->rbsp_len));
if (err)
{
fprintf(stderr,"### Error removing emulation prevention bytes\n");
fprint_err("### Error removing emulation prevention bytes\n");
return 1;
}
}
@ -298,7 +299,7 @@ static inline int prepare_rbsp(nal_unit_p nal)
err = build_bitdata(&bd,nal->rbsp,nal->rbsp_len);
if (err)
{
fprintf(stderr,"### Unable to build bitdata datastructure for NAL RBSP\n");
fprint_err("### Unable to build bitdata datastructure for NAL RBSP\n");
return 1;
}
nal->bit_data = bd;
@ -333,7 +334,7 @@ static int read_slice_data(nal_unit_p nal,
#define CHECK(name) \
if (err) \
{ \
fprintf(stderr,"### Error reading %s field from slice data\n",(name)); \
fprint_err("### Error reading %s field from slice data\n",(name)); \
}
err = read_exp_golomb(bd,&data->first_mb_in_slice);
@ -504,7 +505,7 @@ static int read_pic_param_set_data(nal_unit_p nal,
#define CHECK(name) \
if (err) \
{ \
fprintf(stderr,"### Error reading %s field from picture parameter set\n", \
fprint_err("### Error reading %s field from picture parameter set\n", \
(name)); \
}
@ -692,7 +693,7 @@ static int read_seq_param_set_data(nal_unit_p nal,
#define CHECK(name) \
if (err) \
{ \
fprintf(stderr,"### Error reading %s field from sequence parameter set\n",\
fprint_err("### Error reading %s field from sequence parameter set\n",\
(name)); \
}
@ -709,7 +710,7 @@ static int read_seq_param_set_data(nal_unit_p nal,
if (reserved_zero_5bits != 0)
{
fprintf(stderr,"### reserved_zero_5bits not zero (%d) in sequence"
fprint_err("### reserved_zero_5bits not zero (%d) in sequence"
" parameter set NAL unit at " OFFSET_T_FORMAT "/%d\n",
reserved_zero_5bits,
nal->unit.start_posn.infile,nal->unit.start_posn.inpacket);
@ -841,7 +842,7 @@ static int read_SEI_recovery_point(nal_unit_p nal,
#define CHECK(name) \
if (err) \
{ \
fprintf(stderr,"### Error reading %s field from SEI\n", \
fprint_err("### Error reading %s field from SEI\n", \
(name)); \
}
@ -890,7 +891,7 @@ static int read_SEI(nal_unit_p nal,
#define CHECK(name) \
if (err) \
{ \
fprintf(stderr,"### Error reading %s field from SEI\n", \
fprint_err("### Error reading %s field from SEI\n", \
(name)); \
}
@ -977,7 +978,7 @@ static int read_rbsp_data(nal_unit_p nal,
if (err)
{
fprintf(stderr,"### Error reading RBSP data for %s NAL (ref idc %x,"
fprint_err("### Error reading RBSP data for %s NAL (ref idc %x,"
" unit type %x) at " OFFSET_T_FORMAT_08 "/%04d\n",
NAL_UNIT_TYPE_STR(nal->nal_unit_type),
nal->nal_ref_idc,
@ -1102,7 +1103,7 @@ extern int nal_is_first_VCL_NAL(nal_unit_p nal,
if (!nal->decoded)
{
fprintf(stderr,"### Cannot decide if NAL unit is first VCL NAL\n"
fprint_err("### Cannot decide if NAL unit is first VCL NAL\n"
" its RBSP data has not been interpreted\n");
return FALSE;
}
@ -1179,11 +1180,11 @@ extern int nal_is_first_VCL_NAL(nal_unit_p nal,
*
* This is intended as a single line of information.
*/
extern void report_nal(FILE *stream,
extern void report_nal(int is_msg,
nal_unit_p nal)
{
if (nal == NULL)
fprintf(stream,".............: NAL unit <null>\n");
fprint_msg_or_err(is_msg,".............: NAL unit <null>\n");
else if (nal_is_slice(nal) && (nal->nal_unit_type == NAL_IDR ||
nal->nal_unit_type == NAL_NON_IDR))
{
@ -1192,54 +1193,54 @@ extern void report_nal(FILE *stream,
snprintf(what,SARRAYSIZE,"(%s)",NAL_UNIT_TYPE_STR(nal->nal_unit_type));
// On Windows, snprintf does not guarantee to write a terminating NULL
what[SARRAYSIZE-1] = '\0';
fprintf(stream,OFFSET_T_FORMAT_08 "/%04d: %x/%02x %-20s %u (%s) frame %u",
nal->unit.start_posn.infile,
nal->unit.start_posn.inpacket,
nal->nal_ref_idc,
nal->nal_unit_type,
what,
nal->u.slice.slice_type,
NAL_SLICE_TYPE_STR(nal->u.slice.slice_type),
nal->u.slice.frame_num);
fprint_msg_or_err(is_msg,OFFSET_T_FORMAT_08 "/%04d: %x/%02x %-20s %u (%s) frame %u",
nal->unit.start_posn.infile,
nal->unit.start_posn.inpacket,
nal->nal_ref_idc,
nal->nal_unit_type,
what,
nal->u.slice.slice_type,
NAL_SLICE_TYPE_STR(nal->u.slice.slice_type),
nal->u.slice.frame_num);
if (nal->u.slice.field_pic_flag)
{
if (nal->u.slice.bottom_field_flag)
fprintf(stream," [bottom]");
fprint_msg_or_err(is_msg," [bottom]");
else
fprintf(stream," [top]");
fprint_msg_or_err(is_msg," [top]");
}
}
else if (nal_is_seq_param_set(nal))
{
fprintf(stream,OFFSET_T_FORMAT_08 "/%04d: %x/%02x (%s %u)",
nal->unit.start_posn.infile,
nal->unit.start_posn.inpacket,
nal->nal_ref_idc,
nal->nal_unit_type,
NAL_UNIT_TYPE_STR(nal->nal_unit_type),
nal->u.seq.seq_parameter_set_id);
fprint_msg_or_err(is_msg,OFFSET_T_FORMAT_08 "/%04d: %x/%02x (%s %u)",
nal->unit.start_posn.infile,
nal->unit.start_posn.inpacket,
nal->nal_ref_idc,
nal->nal_unit_type,
NAL_UNIT_TYPE_STR(nal->nal_unit_type),
nal->u.seq.seq_parameter_set_id);
}
else if (nal_is_pic_param_set(nal))
{
fprintf(stream,OFFSET_T_FORMAT_08 "/%04d: %x/%02x (%s %u)",
nal->unit.start_posn.infile,
nal->unit.start_posn.inpacket,
nal->nal_ref_idc,
nal->nal_unit_type,
NAL_UNIT_TYPE_STR(nal->nal_unit_type),
nal->u.pic.pic_parameter_set_id);
fprint_msg_or_err(is_msg,OFFSET_T_FORMAT_08 "/%04d: %x/%02x (%s %u)",
nal->unit.start_posn.infile,
nal->unit.start_posn.inpacket,
nal->nal_ref_idc,
nal->nal_unit_type,
NAL_UNIT_TYPE_STR(nal->nal_unit_type),
nal->u.pic.pic_parameter_set_id);
}
else
fprintf(stream,OFFSET_T_FORMAT_08 "/%04d: %x/%02x (%s)",
nal->unit.start_posn.infile,
nal->unit.start_posn.inpacket,
nal->nal_ref_idc,
nal->nal_unit_type,
NAL_UNIT_TYPE_STR(nal->nal_unit_type));
fprint_msg_or_err(is_msg,OFFSET_T_FORMAT_08 "/%04d: %x/%02x (%s)",
nal->unit.start_posn.infile,
nal->unit.start_posn.inpacket,
nal->nal_ref_idc,
nal->nal_unit_type,
NAL_UNIT_TYPE_STR(nal->nal_unit_type));
#if REPORT_NAL_SHOWS_ADDRESS
fprintf(stream," <%p>",nal);
fprint_msg_or_err(is_msg," <%p>",nal);
#endif
fprintf(stream,"\n");
fprint_msg_or_err(is_msg,"\n");
}
// ------------------------------------------------------------
@ -1262,14 +1263,14 @@ static void check_profile(nal_unit_p nal,
if (nal == NULL)
{
fprintf(stderr,"### Attempt to check profile on a NULL NAL unit\n");
fprint_err("### Attempt to check profile on a NULL NAL unit\n");
return;
}
else if (nal->nal_unit_type != 7)
{
fprintf(stderr,"### Attempt to check profile on a NAL unit that is not a "
fprint_err("### Attempt to check profile on a NAL unit that is not a "
"sequence parameter set\n");
report_nal(stderr,nal);
report_nal(FALSE,nal);
return;
}
else if (!nal->decoded)
@ -1280,7 +1281,7 @@ static void check_profile(nal_unit_p nal,
int err = read_rbsp_data(nal,NULL,NULL,show_nal_details);
if (err)
{
fprintf(stderr,"### Error trying to decode RBSP for first sequence"
fprint_err("### Error trying to decode RBSP for first sequence"
" parameter set\n");
return;
}
@ -1297,23 +1298,23 @@ static void check_profile(nal_unit_p nal,
{
int sum = data.constraint_set0_flag + data.constraint_set1_flag +
data.constraint_set2_flag;
fprintf(stderr,"\n");
fprintf(stderr,"Warning: This bitstream declares itself as %s profile (%d)",
fprint_err("\n");
fprint_err("Warning: This bitstream declares itself as %s profile (%d)",
name,data.profile_idc);
if (sum == 0)
fprintf(stderr,".\n");
fprint_err(".\n");
else
{
fprintf(stderr,",\n");
fprintf(stderr," and as obeying the constraints of the");
if (data.constraint_set0_flag) fprintf(stderr," baseline");
if (data.constraint_set1_flag) fprintf(stderr," main");
if (data.constraint_set2_flag) fprintf(stderr," extended");
fprintf(stderr," profile%s.\n",(sum==1?"":"s"));
fprint_err(",\n");
fprint_err(" and as obeying the constraints of the");
if (data.constraint_set0_flag) fprint_err(" baseline");
if (data.constraint_set1_flag) fprint_err(" main");
if (data.constraint_set2_flag) fprint_err(" extended");
fprint_err(" profile%s.\n",(sum==1?"":"s"));
}
fprintf(stderr," This software does not support %s profile,\n",
fprint_err(" This software does not support %s profile,\n",
name);
fprintf(stderr," and may give incorrect results or fail.\n\n");
fprint_err(" and may give incorrect results or fail.\n\n");
return;
}
}
@ -1349,14 +1350,14 @@ extern int setup_NAL_data(int verbose,
forbidden_zero_bit = nal->data[0] & 0x80;
if (forbidden_zero_bit)
{
fprintf(stderr,"### NAL forbidden_zero_bit is non-zero, at "
fprint_err("### NAL forbidden_zero_bit is non-zero, at "
OFFSET_T_FORMAT "/%d\n",
nal->unit.start_posn.infile,nal->unit.start_posn.inpacket);
fprintf(stderr," First byte of NAL unit is %02x",nal->data[0]);
fprint_err(" First byte of NAL unit is %02x",nal->data[0]);
if (nal->data[0] == 0xB3)
fprintf(stderr,", which is H.262 sequence header start code\n"
fprint_err(", which is H.262 sequence header start code\n"
" Data may be MPEG-1 or MPEG-2");
fprintf(stderr,"\n");
fprint_err("\n");
return 1;
}
nal->nal_ref_idc = (nal->data[0] & 0x60) >> 5;
@ -1369,10 +1370,10 @@ extern int setup_NAL_data(int verbose,
snprintf(what,SARRAYSIZE2,"(%s)",NAL_UNIT_TYPE_STR(nal->nal_unit_type));
// On Windows, snprintf does not guarantee to write a terminating NULL
what[SARRAYSIZE2-1] = '\0';
fprintf(stdout,OFFSET_T_FORMAT_08 "/%04d: NAL unit %d/%d %-20s",
nal->unit.start_posn.infile,
nal->unit.start_posn.inpacket,
nal->nal_ref_idc,nal->nal_unit_type,what);
fprint_msg(OFFSET_T_FORMAT_08 "/%04d: NAL unit %d/%d %-20s",
nal->unit.start_posn.infile,
nal->unit.start_posn.inpacket,
nal->nal_ref_idc,nal->nal_unit_type,what);
// Show the start of the data bytes. This is a tailored form of what
// `print_data` would do, more suited to our purposes here (i.e.,
@ -1381,13 +1382,13 @@ extern int setup_NAL_data(int verbose,
{
int ii;
int show_len = (nal->data_len>10?10:nal->data_len);
fprintf(stdout," %6d:",nal->data_len);
fprint_msg(" %6d:",nal->data_len);
for (ii = 0; ii < show_len; ii++)
fprintf(stdout," %02x",nal->data[ii]);
fprint_msg(" %02x",nal->data[ii]);
if (show_len < nal->data_len)
fprintf(stdout,"...");
print_msg("...");
}
fprintf(stdout,"\n");
print_msg("\n");
}
return 0;
}
@ -1467,8 +1468,8 @@ extern int find_next_NAL_unit(nal_unit_context_p context,
(*nal)->u.pic.pic_parameter_set_id,*nal);
if (err)
{
fprintf(stderr,"### Error remembering picture parameter set ");
report_nal(stderr,*nal);
fprint_err("### Error remembering picture parameter set ");
report_nal(FALSE,*nal);
free_nal_unit(nal);
return 1;
}
@ -1479,8 +1480,8 @@ extern int find_next_NAL_unit(nal_unit_context_p context,
(*nal)->u.seq.seq_parameter_set_id,*nal);
if (err)
{
fprintf(stderr,"### Error remembering sequence parameter set ");
report_nal(stderr,*nal);
fprint_err("### Error remembering sequence parameter set ");
report_nal(FALSE,*nal);
free_nal_unit(nal);
return 1;
}
@ -1503,7 +1504,7 @@ extern int write_NAL_unit_as_ES(FILE *output,
int err = write_ES_unit(output,&(nal->unit));
if (err)
{
fprintf(stderr,"### Error writing NAL unit as ES\n");
fprint_err("### Error writing NAL unit as ES\n");
return err;
}
else
@ -1532,7 +1533,7 @@ extern int write_NAL_unit_as_TS(TS_writer_p tswriter,
video_pid,DEFAULT_VIDEO_STREAM_ID);
if (err)
{
fprintf(stderr,"### Error writing NAL unit as TS\n");
fprint_err("### Error writing NAL unit as TS\n");
return err;
}
else
@ -1553,7 +1554,7 @@ extern int build_param_dict(param_dict_p *param_dict)
param_dict_p new = malloc(SIZEOF_PARAM_DICT);
if (new == NULL)
{
fprintf(stderr,"### Unable to allocate parameter 'dictionary'"
fprint_err("### Unable to allocate parameter 'dictionary'"
" datastructure\n");
return 1;
}
@ -1564,7 +1565,7 @@ extern int build_param_dict(param_dict_p *param_dict)
new->ids = malloc(sizeof(uint32_t)*NAL_PIC_PARAM_START_SIZE);
if (new->ids == NULL)
{
fprintf(stderr,"### Unable to allocate array within 'dictionary'"
fprint_err("### Unable to allocate array within 'dictionary'"
" datastructure\n");
free(new);
return 1;
@ -1573,7 +1574,7 @@ extern int build_param_dict(param_dict_p *param_dict)
new->params = malloc(SIZEOF_NAL_INNARDS*NAL_PIC_PARAM_START_SIZE);
if (new->params == NULL)
{
fprintf(stderr,"### Unable to allocate array within 'dictionary'"
fprint_err("### Unable to allocate array within 'dictionary'"
" datastructure\n");
free(new->ids);
free(new);
@ -1583,7 +1584,7 @@ extern int build_param_dict(param_dict_p *param_dict)
new->posns = malloc(SIZEOF_ES_OFFSET*NAL_PIC_PARAM_START_SIZE);
if (new->posns == NULL)
{
fprintf(stderr,"### Unable to allocate array within 'dictionary'"
fprint_err("### Unable to allocate array within 'dictionary'"
" datastructure\n");
free(new->params);
free(new->ids);
@ -1594,7 +1595,7 @@ extern int build_param_dict(param_dict_p *param_dict)
new->data_lens = malloc(sizeof(uint32_t)*NAL_PIC_PARAM_START_SIZE);
if (new->data_lens == NULL)
{
fprintf(stderr,"### Unable to allocate array within 'dictionary'"
fprint_err("### Unable to allocate array within 'dictionary'"
" datastructure\n");
free(new->params);
free(new->ids);
@ -1679,27 +1680,27 @@ extern int remember_param_data(param_dict_p param_dict,
param_dict->ids = realloc(param_dict->ids,newsize*sizeof(uint32_t));
if (param_dict->ids == NULL)
{
fprintf(stderr,"### Unable to extend parameter set dictionary array\n");
fprint_err("### Unable to extend parameter set dictionary array\n");
return 1;
}
param_dict->params = realloc(param_dict->params,
newsize*SIZEOF_NAL_INNARDS);
if (param_dict->params == NULL)
{
fprintf(stderr,"### Unable to extend parameter set dictionary array\n");
fprint_err("### Unable to extend parameter set dictionary array\n");
return 1;
}
param_dict->posns = realloc(param_dict->params,newsize*SIZEOF_ES_OFFSET);
if (param_dict->posns == NULL)
{
fprintf(stderr,"### Unable to extend parameter set dictionary array\n");
fprint_err("### Unable to extend parameter set dictionary array\n");
return 1;
}
param_dict->data_lens = realloc(param_dict->params,
newsize*sizeof(uint32_t));
if (param_dict->data_lens == NULL)
{
fprintf(stderr,"### Unable to extend parameter set dictionary array\n");
fprint_err("### Unable to extend parameter set dictionary array\n");
return 1;
}
param_dict->size = newsize;
@ -1770,7 +1771,7 @@ extern int get_pic_param_data(param_dict_p pic_param_dict,
int absent = lookup_param_data(pic_param_dict,pic_param_id,&innards);
if (absent)
{
fprintf(stderr,"### Unable to find picture parameter set with id %u\n",
fprint_err("### Unable to find picture parameter set with id %u\n",
pic_param_id);
return 1;
}
@ -1801,7 +1802,7 @@ extern int get_seq_param_data(param_dict_p seq_param_dict,
int absent = lookup_param_data(seq_param_dict,seq_param_id,&innards);
if (absent)
{
fprintf(stderr,"### Unable to find sequence parameter set with id %u\n",
fprint_err("### Unable to find sequence parameter set with id %u\n",
seq_param_id);
return 1;
}
@ -1828,7 +1829,7 @@ extern int build_nal_unit_list(nal_unit_list_p *list)
nal_unit_list_p new = malloc(SIZEOF_NAL_UNIT_LIST);
if (new == NULL)
{
fprintf(stderr,"### Unable to allocate NAL unit list datastructure\n");
fprint_err("### Unable to allocate NAL unit list datastructure\n");
return 1;
}
@ -1838,7 +1839,7 @@ extern int build_nal_unit_list(nal_unit_list_p *list)
if (new->array == NULL)
{
free(new);
fprintf(stderr,
fprint_err(
"### Unable to allocate array in NAL unit list datastructure\n");
return 1;
}
@ -1861,7 +1862,7 @@ extern int append_to_nal_unit_list(nal_unit_list_p list,
list->array = realloc(list->array,newsize*sizeof(nal_unit_p));
if (list->array == NULL)
{
fprintf(stderr,"### Unable to extend NAL unit list array\n");
fprint_err("### Unable to extend NAL unit list array\n");
return 1;
}
list->size = newsize;
@ -1956,21 +1957,21 @@ extern void free_nal_unit_list(nal_unit_list_p *list,
/*
* Report on a NAL unit list's contents, to the given stream.
*/
extern void report_nal_unit_list(FILE *stream,
extern void report_nal_unit_list(int is_msg,
char *prefix,
nal_unit_list_p list)
{
if (prefix == NULL)
prefix = "";
if (list->array == NULL)
fprintf(stream,"%s<empty>\n",prefix);
fprint_msg_or_err(is_msg,"%s<empty>\n",prefix);
else
{
int ii;
for (ii=0; ii<list->length; ii++)
{
fprintf(stream,"%s",prefix);
report_nal(stream,list->array[ii]);
fprint_msg_or_err(is_msg,"%s",prefix);
report_nal(is_msg,list->array[ii]);
}
}
}

Wyświetl plik

@ -331,7 +331,7 @@ extern void free_nal_unit_list(nal_unit_list_p *list,
/*
* Report on a NAL unit list's contents, to the given stream.
*/
extern void report_nal_unit_list(FILE *stream,
extern void report_nal_unit_list(int is_msg,
char *prefix,
nal_unit_list_p list);
@ -340,7 +340,7 @@ extern void report_nal_unit_list(FILE *stream,
*
* This is intended as a single line of information.
*/
extern void report_nal(FILE *stream,
extern void report_nal(int is_msg,
nal_unit_p nal);
#endif // _nalunit_fns

Wyświetl plik

@ -161,13 +161,13 @@ extern void fprint_err(const char *format, ...)
/*
* Prints the given formatted text, as a normal or error message.
* If `normal`, then as a normal message, else as an error
* If `is_msg`, then as a normal message, else as an error
*/
extern void fprint_msg_or_err(int normal, const char *format, ...)
extern void fprint_msg_or_err(int is_msg, const char *format, ...)
{
va_list va_arg;
va_start(va_arg, format);
if (normal)
if (is_msg)
{
#if DEBUG
printf("?m:%p %s",fns.fprint_message_fn,format);

Wyświetl plik

@ -52,9 +52,9 @@ extern void fprint_msg(const char *format, ...);
extern void fprint_err(const char *format, ...);
/*
* Prints the given formatted text, as a normal or error message.
* If `normal`, then as a normal message, else as an error
* If `is_msg`, then as a normal message, else as an error
*/
extern void fprint_msg_or_err(int normal, const char *format, ...);
extern void fprint_msg_or_err(int is_msg, const char *format, ...);
// ============================================================
// Choosing what the printing functions do