kopia lustrzana https://github.com/F5OEO/tstools
Start of converting printf (etc) to the new message functions.
--HG-- extra : convert_revision : svn%3Aeff31bef-be4a-0410-a8fe-e47997df2690/trunk%40130issue20
rodzic
0763ebb39c
commit
ef5a9ea9f9
31
ac3.c
31
ac3.c
|
@ -33,6 +33,7 @@
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
#include "printing_fns.h"
|
||||||
#include "misc_fns.h"
|
#include "misc_fns.h"
|
||||||
#include "ac3_fns.h"
|
#include "ac3_fns.h"
|
||||||
|
|
||||||
|
@ -91,18 +92,18 @@ int read_next_ac3_frame(int file,
|
||||||
return EOF;
|
return EOF;
|
||||||
else if (err)
|
else if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "### Error reading syncinfo from AC3 file\n");
|
fprint_err("### Error reading syncinfo from AC3 file\n"
|
||||||
fprintf(stderr, " (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
|
" (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (sync_info[0] != 0x0b || sync_info[1] != 0x77)
|
if (sync_info[0] != 0x0b || sync_info[1] != 0x77)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "### AC3 frame does not start with 0x0b77"
|
fprint_err("### AC3 frame does not start with 0x0b77"
|
||||||
" syncword - lost synchronisation?\n"
|
" syncword - lost synchronisation?\n"
|
||||||
" Found 0x%02x%02x instead of 0x0b77\n",
|
" Found 0x%02x%02x instead of 0x0b77\n",
|
||||||
(unsigned)sync_info[0], (unsigned)sync_info[1]);
|
(unsigned)sync_info[0], (unsigned)sync_info[1]);
|
||||||
fprintf(stderr, " (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
|
fprint_err(" (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -110,17 +111,17 @@ int read_next_ac3_frame(int file,
|
||||||
if (fscod == 3)
|
if (fscod == 3)
|
||||||
{
|
{
|
||||||
// Bad sample rate code
|
// Bad sample rate code
|
||||||
fprintf(stderr, "### Bad sample rate code in AC3 syncinfo\n");
|
fprint_err("### Bad sample rate code in AC3 syncinfo\n"
|
||||||
fprintf(stderr, " (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
|
" (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
frmsizecod = sync_info[4] & 0x3f;
|
frmsizecod = sync_info[4] & 0x3f;
|
||||||
if (frmsizecod > 37)
|
if (frmsizecod > 37)
|
||||||
{
|
{
|
||||||
fprintf(stderr, "### Bad frame size code %d in AC3 syncinfo\n",
|
fprint_err("### Bad frame size code %d in AC3 syncinfo\n",
|
||||||
frmsizecod);
|
frmsizecod);
|
||||||
fprintf(stderr, " (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
|
fprint_err(" (in frame starting at " OFFSET_T_FORMAT ")\n", posn);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -132,7 +133,7 @@ int read_next_ac3_frame(int file,
|
||||||
data = malloc(frame_length);
|
data = malloc(frame_length);
|
||||||
if (data == NULL)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
for (i = 0; i < SYNCINFO_SIZE; i++)
|
for (i = 0; i < SYNCINFO_SIZE; i++)
|
||||||
|
@ -143,9 +144,9 @@ int read_next_ac3_frame(int file,
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
if (err == EOF)
|
if (err == EOF)
|
||||||
fprintf(stderr, "### Unexpected EOF reading rest of AC3 frame\n");
|
print_err("### Unexpected EOF reading rest of AC3 frame\n");
|
||||||
else
|
else
|
||||||
fprintf(stderr, "### Error reading rest of AC3 frame\n");
|
print_err("### Error reading rest of AC3 frame\n");
|
||||||
free(data);
|
free(data);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
124
accessunit.c
124
accessunit.c
|
@ -30,6 +30,7 @@
|
||||||
#include <stdlib.h>
|
#include <stdlib.h>
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
#include "printing_fns.h"
|
||||||
#include "es_fns.h"
|
#include "es_fns.h"
|
||||||
#include "ts_fns.h"
|
#include "ts_fns.h"
|
||||||
#include "nalunit_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);
|
access_unit_p new = malloc(SIZEOF_ACCESS_UNIT);
|
||||||
if (new == NULL)
|
if (new == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Unable to allocate access unit datastructure\n");
|
print_err("### Unable to allocate access unit datastructure\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -134,7 +135,7 @@ extern void report_access_unit(FILE *stream,
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stream," %c",((access_unit->primary_start == nal)?'*':' '));
|
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;
|
int ii;
|
||||||
if (access_unit->primary_start == NULL)
|
if (access_unit->primary_start == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
print_err("### Cannot determine bounds of an access unit with no content\n");
|
||||||
"### Cannot determine bounds of an access unit with no content\n");
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -315,8 +315,8 @@ static int access_unit_append(access_unit_p access_unit,
|
||||||
if (starts_primary && access_unit->started_primary_picture)
|
if (starts_primary && access_unit->started_primary_picture)
|
||||||
{
|
{
|
||||||
// Our caller should have started a new access unit instead
|
// Our caller should have started a new access unit instead
|
||||||
fprintf(stderr,"### Already had a start of primary picture in access"
|
fprint_err("### Already had a start of primary picture in access"
|
||||||
" unit %d\n",access_unit->index);
|
" unit %d\n",access_unit->index);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,8 +337,8 @@ static int access_unit_append(access_unit_p access_unit,
|
||||||
pending->array[ii]);
|
pending->array[ii]);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error extending access unit %d\n",
|
fprint_err("### Error extending access unit %d\n",
|
||||||
access_unit->index);
|
access_unit->index);
|
||||||
return err;
|
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);
|
err = append_to_nal_unit_list(access_unit->nal_units,nal);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error extending access unit %d\n",
|
fprint_err("### Error extending access unit %d\n",
|
||||||
access_unit->index);
|
access_unit->index);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -374,7 +374,7 @@ static int merge_access_unit_nals(access_unit_p access_unit1,
|
||||||
(*access_unit2)->nal_units->array[ii]);
|
(*access_unit2)->nal_units->array[ii]);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error merging two access units\n");
|
print_err("### Error merging two access units\n");
|
||||||
return err;
|
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));
|
err = write_ES_unit(output,&(access_unit->nal_units->array[ii]->unit));
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error writing NAL unit ");
|
print_err("### Error writing NAL unit ");
|
||||||
report_nal(stderr,access_unit->nal_units->array[ii]);
|
report_nal(FALSE,access_unit->nal_units->array[ii]);
|
||||||
return err;
|
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));
|
err = write_ES_unit(output,&(context->end_of_sequence->unit));
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error writing end of sequence NAL unit ");
|
print_err("### Error writing end of sequence NAL unit ");
|
||||||
report_nal(stderr,context->end_of_sequence);
|
report_nal(FALSE,context->end_of_sequence);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
free_nal_unit(&context->end_of_sequence);
|
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));
|
err = write_ES_unit(output,&(context->end_of_stream->unit));
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error writing end of stream NAL unit ");
|
print_err("### Error writing end of stream NAL unit ");
|
||||||
report_nal(stderr,context->end_of_sequence);
|
report_nal(FALSE,context->end_of_sequence);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
free_nal_unit(&context->end_of_stream);
|
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);
|
video_pid,DEFAULT_VIDEO_STREAM_ID);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error writing end of sequence NAL unit ");
|
print_err("### Error writing end of sequence NAL unit ");
|
||||||
report_nal(stderr,nal);
|
report_nal(FALSE,nal);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
free_nal_unit(&context->end_of_sequence);
|
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);
|
video_pid,DEFAULT_VIDEO_STREAM_ID);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error writing end of stream NAL unit ");
|
print_err("### Error writing end of stream NAL unit ");
|
||||||
report_nal(stderr,nal);
|
report_nal(FALSE,nal);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
free_nal_unit(&context->end_of_stream);
|
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);
|
video_pid,DEFAULT_VIDEO_STREAM_ID);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error writing NAL unit ");
|
print_err("### Error writing NAL unit ");
|
||||||
report_nal(stderr,nal);
|
report_nal(FALSE,nal);
|
||||||
return err;
|
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);
|
video_pid,DEFAULT_VIDEO_STREAM_ID);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error writing NAL unit ");
|
print_err("### Error writing NAL unit ");
|
||||||
report_nal(stderr,nal);
|
report_nal(FALSE,nal);
|
||||||
return err;
|
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);
|
video_pid,DEFAULT_VIDEO_STREAM_ID);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error writing NAL unit ");
|
print_err("### Error writing NAL unit ");
|
||||||
report_nal(stderr,nal);
|
report_nal(FALSE,nal);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -676,17 +676,17 @@ static inline int end_access_unit(access_unit_context_p context,
|
||||||
if (context->pending_nal)
|
if (context->pending_nal)
|
||||||
{
|
{
|
||||||
printf("... pending: ");
|
printf("... pending: ");
|
||||||
report_nal(stdout,context->pending_nal);
|
report_nal(TRUE,context->pending_nal);
|
||||||
}
|
}
|
||||||
if (context->end_of_sequence)
|
if (context->end_of_sequence)
|
||||||
{
|
{
|
||||||
printf("--> EndOfSequence ");
|
printf("--> EndOfSequence ");
|
||||||
report_nal(stdout,context->end_of_sequence);
|
report_nal(TRUE,context->end_of_sequence);
|
||||||
}
|
}
|
||||||
if (context->end_of_stream)
|
if (context->end_of_stream)
|
||||||
{
|
{
|
||||||
printf("--> EndOfStream ");
|
printf("--> EndOfStream ");
|
||||||
report_nal(stdout,context->end_of_stream);
|
report_nal(TRUE,context->end_of_stream);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return 0;
|
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);
|
access_unit_context_p new = malloc(SIZEOF_ACCESS_UNIT_CONTEXT);
|
||||||
if (new == NULL)
|
if (new == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
print_err("### Unable to allocate access unit context datastructure\n");
|
||||||
"### Unable to allocate access unit context datastructure\n");
|
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -720,14 +719,14 @@ extern int build_access_unit_context(ES_p es,
|
||||||
err = build_nal_unit_context(es,&new->nac);
|
err = build_nal_unit_context(es,&new->nac);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error building access unit context datastructure\n");
|
print_err("### Error building access unit context datastructure\n");
|
||||||
free(new);
|
free(new);
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
err = build_nal_unit_list(&new->pending_list);
|
err = build_nal_unit_list(&new->pending_list);
|
||||||
if (err)
|
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_nal_unit_context(&new->nac);
|
||||||
free(new);
|
free(new);
|
||||||
return err;
|
return err;
|
||||||
|
@ -850,8 +849,7 @@ static int remember_earlier_primary_start(access_unit_context_p context,
|
||||||
int err = build_nal_unit(&tgt);
|
int err = build_nal_unit(&tgt);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,
|
print_err("### Error building NAL unit for 'earlier primary start'\n");
|
||||||
"### Error building NAL unit for 'earlier primary start'\n");
|
|
||||||
free(tgt);
|
free(tgt);
|
||||||
return err;
|
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);
|
int err = get_access_unit_bounds(access_unit,&start_posn,&num_bytes);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error working out position/size of access unit %d"
|
fprint_err("### Error working out position/size of access unit %d"
|
||||||
" for reversing\n",access_unit->index);
|
" for reversing\n",access_unit->index);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
err = remember_reverse_h264_data(reverse_data,access_unit->index,
|
err = remember_reverse_h264_data(reverse_data,access_unit->index,
|
||||||
start_posn,num_bytes);
|
start_posn,num_bytes);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error remembering access unit %d for reversing\n",
|
fprint_err("### Error remembering access unit %d for reversing\n",
|
||||||
access_unit->index);
|
access_unit->index);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
if (verbose) printf("REMEMBER IDR %5d at " OFFSET_T_FORMAT_08
|
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).
|
// unit).
|
||||||
// Clearly, option (a) is the easiest to try, so let's see how that
|
// Clearly, option (a) is the easiest to try, so let's see how that
|
||||||
// works for now...
|
// works for now...
|
||||||
fprintf(stderr,"!!! Ignoring broken NAL unit\n");
|
print_err("!!! Ignoring broken NAL unit\n");
|
||||||
access_unit->ignored_broken_NAL_units ++;
|
access_unit->ignored_broken_NAL_units ++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
else if (err)
|
else if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error retrieving next NAL\n");
|
print_err("### Error retrieving next NAL\n");
|
||||||
goto give_up;
|
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?
|
// access unit. So what should we do? Ignore it?
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"!!! Ignoring VCL NAL that cannot start a picture:\n");
|
print_err("!!! Ignoring VCL NAL that cannot start a picture:\n");
|
||||||
fprintf(stderr," ");
|
print_err(" ");
|
||||||
report_nal(stderr,nal);
|
report_nal(FALSE,nal);
|
||||||
fprintf(stderr,"\n");
|
print_err("\n");
|
||||||
}
|
}
|
||||||
free_nal_unit(&nal);
|
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 ||
|
if (context->pending_list->length > 0 ||
|
||||||
access_unit->nal_units->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)
|
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);
|
reset_nal_unit_list(access_unit->nal_units,TRUE);
|
||||||
}
|
}
|
||||||
if (context->pending_list->length > 0)
|
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);
|
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)
|
if (context->pending_list->length > 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"!!! Ignoring items after last VCL NAL and"
|
print_err("!!! Ignoring items after last VCL NAL and"
|
||||||
" before End of Sequence:\n");
|
" before End of Sequence:\n");
|
||||||
report_nal_unit_list(stderr," ",context->pending_list);
|
report_nal_unit_list(FALSE," ",context->pending_list);
|
||||||
reset_nal_unit_list(context->pending_list,TRUE);
|
reset_nal_unit_list(context->pending_list,TRUE);
|
||||||
}
|
}
|
||||||
// And remember this as the End of Sequence marker
|
// 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)
|
if (context->pending_list->length > 0)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"!!! Ignoring items after last VCL NAL and"
|
print_err("!!! Ignoring items after last VCL NAL and"
|
||||||
" before End of Stream:\n");
|
" before End of Stream:\n");
|
||||||
report_nal_unit_list(stderr," ",context->pending_list);
|
report_nal_unit_list(FALSE," ",context->pending_list);
|
||||||
reset_nal_unit_list(context->pending_list,TRUE);
|
reset_nal_unit_list(context->pending_list,TRUE);
|
||||||
}
|
}
|
||||||
// And remember this as the End of Stream marker
|
// 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)
|
||||||
{
|
{
|
||||||
if (err != EOF)
|
if (err != EOF)
|
||||||
fprintf(stderr,"### Trying to read second field\n");
|
print_err("### Trying to read second field\n");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (second->field_pic_flag == 0)
|
if (second->field_pic_flag == 0)
|
||||||
{
|
{
|
||||||
if (!quiet)
|
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);
|
free_access_unit(access_unit);
|
||||||
*access_unit = second;
|
*access_unit = second;
|
||||||
// and pretend to success
|
// and pretend to success
|
||||||
|
@ -1309,10 +1307,10 @@ static int get_next_field_of_pair(access_unit_context_p context,
|
||||||
else if (first_time)
|
else if (first_time)
|
||||||
{
|
{
|
||||||
if (!quiet)
|
if (!quiet)
|
||||||
fprintf(stderr,"!!! Field with frame number %d (%x) followed by"
|
fprint_err("!!! Field with frame number %d (%x) followed by"
|
||||||
" field with frame number %d (%x) - ignoring first field\n",
|
" field with frame number %d (%x) - ignoring first field\n",
|
||||||
(*access_unit)->frame_num,(*access_unit)->frame_num,
|
(*access_unit)->frame_num,(*access_unit)->frame_num,
|
||||||
second->frame_num,second->frame_num);
|
second->frame_num,second->frame_num);
|
||||||
|
|
||||||
// Try again
|
// Try again
|
||||||
free_access_unit(access_unit);
|
free_access_unit(access_unit);
|
||||||
|
@ -1322,8 +1320,8 @@ static int get_next_field_of_pair(access_unit_context_p context,
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Adjacent fields do not share frame numbers"
|
print_err("### Adjacent fields do not share frame numbers"
|
||||||
" - unable to match fields up\n");
|
" - unable to match fields up\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
|
|
201
nalunit.c
201
nalunit.c
|
@ -38,6 +38,7 @@
|
||||||
#endif // _WIN32
|
#endif // _WIN32
|
||||||
|
|
||||||
#include "compat.h"
|
#include "compat.h"
|
||||||
|
#include "printing_fns.h"
|
||||||
#include "es_fns.h"
|
#include "es_fns.h"
|
||||||
#include "ts_fns.h"
|
#include "ts_fns.h"
|
||||||
#include "bitdata_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);
|
nal_unit_context_p new = malloc(SIZEOF_NAL_UNIT_CONTEXT);
|
||||||
if (new == NULL)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
new->es = es;
|
new->es = es;
|
||||||
|
@ -149,14 +150,14 @@ extern int build_nal_unit(nal_unit_p *nal)
|
||||||
nal_unit_p new = malloc(SIZEOF_NAL_UNIT);
|
nal_unit_p new = malloc(SIZEOF_NAL_UNIT);
|
||||||
if (new == NULL)
|
if (new == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Unable to allocate NAL unit datastructure\n");
|
fprint_err("### Unable to allocate NAL unit datastructure\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
err = setup_ES_unit(&(new->unit));
|
err = setup_ES_unit(&(new->unit));
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Unable to allocate NAL unit data buffer\n");
|
fprint_err("### Unable to allocate NAL unit data buffer\n");
|
||||||
free(new);
|
free(new);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -247,7 +248,7 @@ static int remove_emulation_prevention(byte data[],
|
||||||
tgt = malloc(data_len);
|
tgt = malloc(data_len);
|
||||||
if (tgt == NULL)
|
if (tgt == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Cannot malloc RBSP target array\n");
|
fprint_err("### Cannot malloc RBSP target array\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -290,7 +291,7 @@ static inline int prepare_rbsp(nal_unit_p nal)
|
||||||
&(nal->rbsp),&(nal->rbsp_len));
|
&(nal->rbsp),&(nal->rbsp_len));
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error removing emulation prevention bytes\n");
|
fprint_err("### Error removing emulation prevention bytes\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -298,7 +299,7 @@ static inline int prepare_rbsp(nal_unit_p nal)
|
||||||
err = build_bitdata(&bd,nal->rbsp,nal->rbsp_len);
|
err = build_bitdata(&bd,nal->rbsp,nal->rbsp_len);
|
||||||
if (err)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
nal->bit_data = bd;
|
nal->bit_data = bd;
|
||||||
|
@ -333,7 +334,7 @@ static int read_slice_data(nal_unit_p nal,
|
||||||
#define CHECK(name) \
|
#define CHECK(name) \
|
||||||
if (err) \
|
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);
|
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) \
|
#define CHECK(name) \
|
||||||
if (err) \
|
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)); \
|
(name)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -692,7 +693,7 @@ static int read_seq_param_set_data(nal_unit_p nal,
|
||||||
#define CHECK(name) \
|
#define CHECK(name) \
|
||||||
if (err) \
|
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)); \
|
(name)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -709,7 +710,7 @@ static int read_seq_param_set_data(nal_unit_p nal,
|
||||||
|
|
||||||
if (reserved_zero_5bits != 0)
|
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",
|
" parameter set NAL unit at " OFFSET_T_FORMAT "/%d\n",
|
||||||
reserved_zero_5bits,
|
reserved_zero_5bits,
|
||||||
nal->unit.start_posn.infile,nal->unit.start_posn.inpacket);
|
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) \
|
#define CHECK(name) \
|
||||||
if (err) \
|
if (err) \
|
||||||
{ \
|
{ \
|
||||||
fprintf(stderr,"### Error reading %s field from SEI\n", \
|
fprint_err("### Error reading %s field from SEI\n", \
|
||||||
(name)); \
|
(name)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -890,7 +891,7 @@ static int read_SEI(nal_unit_p nal,
|
||||||
#define CHECK(name) \
|
#define CHECK(name) \
|
||||||
if (err) \
|
if (err) \
|
||||||
{ \
|
{ \
|
||||||
fprintf(stderr,"### Error reading %s field from SEI\n", \
|
fprint_err("### Error reading %s field from SEI\n", \
|
||||||
(name)); \
|
(name)); \
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -977,7 +978,7 @@ static int read_rbsp_data(nal_unit_p nal,
|
||||||
|
|
||||||
if (err)
|
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",
|
" unit type %x) at " OFFSET_T_FORMAT_08 "/%04d\n",
|
||||||
NAL_UNIT_TYPE_STR(nal->nal_unit_type),
|
NAL_UNIT_TYPE_STR(nal->nal_unit_type),
|
||||||
nal->nal_ref_idc,
|
nal->nal_ref_idc,
|
||||||
|
@ -1102,7 +1103,7 @@ extern int nal_is_first_VCL_NAL(nal_unit_p nal,
|
||||||
|
|
||||||
if (!nal->decoded)
|
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");
|
" its RBSP data has not been interpreted\n");
|
||||||
return FALSE;
|
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.
|
* 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)
|
nal_unit_p nal)
|
||||||
{
|
{
|
||||||
if (nal == NULL)
|
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 ||
|
else if (nal_is_slice(nal) && (nal->nal_unit_type == NAL_IDR ||
|
||||||
nal->nal_unit_type == NAL_NON_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));
|
snprintf(what,SARRAYSIZE,"(%s)",NAL_UNIT_TYPE_STR(nal->nal_unit_type));
|
||||||
// On Windows, snprintf does not guarantee to write a terminating NULL
|
// On Windows, snprintf does not guarantee to write a terminating NULL
|
||||||
what[SARRAYSIZE-1] = '\0';
|
what[SARRAYSIZE-1] = '\0';
|
||||||
fprintf(stream,OFFSET_T_FORMAT_08 "/%04d: %x/%02x %-20s %u (%s) frame %u",
|
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.infile,
|
||||||
nal->unit.start_posn.inpacket,
|
nal->unit.start_posn.inpacket,
|
||||||
nal->nal_ref_idc,
|
nal->nal_ref_idc,
|
||||||
nal->nal_unit_type,
|
nal->nal_unit_type,
|
||||||
what,
|
what,
|
||||||
nal->u.slice.slice_type,
|
nal->u.slice.slice_type,
|
||||||
NAL_SLICE_TYPE_STR(nal->u.slice.slice_type),
|
NAL_SLICE_TYPE_STR(nal->u.slice.slice_type),
|
||||||
nal->u.slice.frame_num);
|
nal->u.slice.frame_num);
|
||||||
if (nal->u.slice.field_pic_flag)
|
if (nal->u.slice.field_pic_flag)
|
||||||
{
|
{
|
||||||
if (nal->u.slice.bottom_field_flag)
|
if (nal->u.slice.bottom_field_flag)
|
||||||
fprintf(stream," [bottom]");
|
fprint_msg_or_err(is_msg," [bottom]");
|
||||||
else
|
else
|
||||||
fprintf(stream," [top]");
|
fprint_msg_or_err(is_msg," [top]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (nal_is_seq_param_set(nal))
|
else if (nal_is_seq_param_set(nal))
|
||||||
{
|
{
|
||||||
fprintf(stream,OFFSET_T_FORMAT_08 "/%04d: %x/%02x (%s %u)",
|
fprint_msg_or_err(is_msg,OFFSET_T_FORMAT_08 "/%04d: %x/%02x (%s %u)",
|
||||||
nal->unit.start_posn.infile,
|
nal->unit.start_posn.infile,
|
||||||
nal->unit.start_posn.inpacket,
|
nal->unit.start_posn.inpacket,
|
||||||
nal->nal_ref_idc,
|
nal->nal_ref_idc,
|
||||||
nal->nal_unit_type,
|
nal->nal_unit_type,
|
||||||
NAL_UNIT_TYPE_STR(nal->nal_unit_type),
|
NAL_UNIT_TYPE_STR(nal->nal_unit_type),
|
||||||
nal->u.seq.seq_parameter_set_id);
|
nal->u.seq.seq_parameter_set_id);
|
||||||
}
|
}
|
||||||
else if (nal_is_pic_param_set(nal))
|
else if (nal_is_pic_param_set(nal))
|
||||||
{
|
{
|
||||||
fprintf(stream,OFFSET_T_FORMAT_08 "/%04d: %x/%02x (%s %u)",
|
fprint_msg_or_err(is_msg,OFFSET_T_FORMAT_08 "/%04d: %x/%02x (%s %u)",
|
||||||
nal->unit.start_posn.infile,
|
nal->unit.start_posn.infile,
|
||||||
nal->unit.start_posn.inpacket,
|
nal->unit.start_posn.inpacket,
|
||||||
nal->nal_ref_idc,
|
nal->nal_ref_idc,
|
||||||
nal->nal_unit_type,
|
nal->nal_unit_type,
|
||||||
NAL_UNIT_TYPE_STR(nal->nal_unit_type),
|
NAL_UNIT_TYPE_STR(nal->nal_unit_type),
|
||||||
nal->u.pic.pic_parameter_set_id);
|
nal->u.pic.pic_parameter_set_id);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
fprintf(stream,OFFSET_T_FORMAT_08 "/%04d: %x/%02x (%s)",
|
fprint_msg_or_err(is_msg,OFFSET_T_FORMAT_08 "/%04d: %x/%02x (%s)",
|
||||||
nal->unit.start_posn.infile,
|
nal->unit.start_posn.infile,
|
||||||
nal->unit.start_posn.inpacket,
|
nal->unit.start_posn.inpacket,
|
||||||
nal->nal_ref_idc,
|
nal->nal_ref_idc,
|
||||||
nal->nal_unit_type,
|
nal->nal_unit_type,
|
||||||
NAL_UNIT_TYPE_STR(nal->nal_unit_type));
|
NAL_UNIT_TYPE_STR(nal->nal_unit_type));
|
||||||
#if REPORT_NAL_SHOWS_ADDRESS
|
#if REPORT_NAL_SHOWS_ADDRESS
|
||||||
fprintf(stream," <%p>",nal);
|
fprint_msg_or_err(is_msg," <%p>",nal);
|
||||||
#endif
|
#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)
|
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;
|
return;
|
||||||
}
|
}
|
||||||
else if (nal->nal_unit_type != 7)
|
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");
|
"sequence parameter set\n");
|
||||||
report_nal(stderr,nal);
|
report_nal(FALSE,nal);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
else if (!nal->decoded)
|
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);
|
int err = read_rbsp_data(nal,NULL,NULL,show_nal_details);
|
||||||
if (err)
|
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");
|
" parameter set\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -1297,23 +1298,23 @@ static void check_profile(nal_unit_p nal,
|
||||||
{
|
{
|
||||||
int sum = data.constraint_set0_flag + data.constraint_set1_flag +
|
int sum = data.constraint_set0_flag + data.constraint_set1_flag +
|
||||||
data.constraint_set2_flag;
|
data.constraint_set2_flag;
|
||||||
fprintf(stderr,"\n");
|
fprint_err("\n");
|
||||||
fprintf(stderr,"Warning: This bitstream declares itself as %s profile (%d)",
|
fprint_err("Warning: This bitstream declares itself as %s profile (%d)",
|
||||||
name,data.profile_idc);
|
name,data.profile_idc);
|
||||||
if (sum == 0)
|
if (sum == 0)
|
||||||
fprintf(stderr,".\n");
|
fprint_err(".\n");
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
fprintf(stderr,",\n");
|
fprint_err(",\n");
|
||||||
fprintf(stderr," and as obeying the constraints of the");
|
fprint_err(" and as obeying the constraints of the");
|
||||||
if (data.constraint_set0_flag) fprintf(stderr," baseline");
|
if (data.constraint_set0_flag) fprint_err(" baseline");
|
||||||
if (data.constraint_set1_flag) fprintf(stderr," main");
|
if (data.constraint_set1_flag) fprint_err(" main");
|
||||||
if (data.constraint_set2_flag) fprintf(stderr," extended");
|
if (data.constraint_set2_flag) fprint_err(" extended");
|
||||||
fprintf(stderr," profile%s.\n",(sum==1?"":"s"));
|
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);
|
name);
|
||||||
fprintf(stderr," and may give incorrect results or fail.\n\n");
|
fprint_err(" and may give incorrect results or fail.\n\n");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1349,14 +1350,14 @@ extern int setup_NAL_data(int verbose,
|
||||||
forbidden_zero_bit = nal->data[0] & 0x80;
|
forbidden_zero_bit = nal->data[0] & 0x80;
|
||||||
if (forbidden_zero_bit)
|
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",
|
OFFSET_T_FORMAT "/%d\n",
|
||||||
nal->unit.start_posn.infile,nal->unit.start_posn.inpacket);
|
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)
|
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");
|
" Data may be MPEG-1 or MPEG-2");
|
||||||
fprintf(stderr,"\n");
|
fprint_err("\n");
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
nal->nal_ref_idc = (nal->data[0] & 0x60) >> 5;
|
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));
|
snprintf(what,SARRAYSIZE2,"(%s)",NAL_UNIT_TYPE_STR(nal->nal_unit_type));
|
||||||
// On Windows, snprintf does not guarantee to write a terminating NULL
|
// On Windows, snprintf does not guarantee to write a terminating NULL
|
||||||
what[SARRAYSIZE2-1] = '\0';
|
what[SARRAYSIZE2-1] = '\0';
|
||||||
fprintf(stdout,OFFSET_T_FORMAT_08 "/%04d: NAL unit %d/%d %-20s",
|
fprint_msg(OFFSET_T_FORMAT_08 "/%04d: NAL unit %d/%d %-20s",
|
||||||
nal->unit.start_posn.infile,
|
nal->unit.start_posn.infile,
|
||||||
nal->unit.start_posn.inpacket,
|
nal->unit.start_posn.inpacket,
|
||||||
nal->nal_ref_idc,nal->nal_unit_type,what);
|
nal->nal_ref_idc,nal->nal_unit_type,what);
|
||||||
|
|
||||||
// Show the start of the data bytes. This is a tailored form of 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.,
|
// `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 ii;
|
||||||
int show_len = (nal->data_len>10?10:nal->data_len);
|
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++)
|
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)
|
if (show_len < nal->data_len)
|
||||||
fprintf(stdout,"...");
|
print_msg("...");
|
||||||
}
|
}
|
||||||
fprintf(stdout,"\n");
|
print_msg("\n");
|
||||||
}
|
}
|
||||||
return 0;
|
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);
|
(*nal)->u.pic.pic_parameter_set_id,*nal);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error remembering picture parameter set ");
|
fprint_err("### Error remembering picture parameter set ");
|
||||||
report_nal(stderr,*nal);
|
report_nal(FALSE,*nal);
|
||||||
free_nal_unit(nal);
|
free_nal_unit(nal);
|
||||||
return 1;
|
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);
|
(*nal)->u.seq.seq_parameter_set_id,*nal);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error remembering sequence parameter set ");
|
fprint_err("### Error remembering sequence parameter set ");
|
||||||
report_nal(stderr,*nal);
|
report_nal(FALSE,*nal);
|
||||||
free_nal_unit(nal);
|
free_nal_unit(nal);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
@ -1503,7 +1504,7 @@ extern int write_NAL_unit_as_ES(FILE *output,
|
||||||
int err = write_ES_unit(output,&(nal->unit));
|
int err = write_ES_unit(output,&(nal->unit));
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error writing NAL unit as ES\n");
|
fprint_err("### Error writing NAL unit as ES\n");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1532,7 +1533,7 @@ extern int write_NAL_unit_as_TS(TS_writer_p tswriter,
|
||||||
video_pid,DEFAULT_VIDEO_STREAM_ID);
|
video_pid,DEFAULT_VIDEO_STREAM_ID);
|
||||||
if (err)
|
if (err)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Error writing NAL unit as TS\n");
|
fprint_err("### Error writing NAL unit as TS\n");
|
||||||
return err;
|
return err;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -1553,7 +1554,7 @@ extern int build_param_dict(param_dict_p *param_dict)
|
||||||
param_dict_p new = malloc(SIZEOF_PARAM_DICT);
|
param_dict_p new = malloc(SIZEOF_PARAM_DICT);
|
||||||
if (new == NULL)
|
if (new == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Unable to allocate parameter 'dictionary'"
|
fprint_err("### Unable to allocate parameter 'dictionary'"
|
||||||
" datastructure\n");
|
" datastructure\n");
|
||||||
return 1;
|
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);
|
new->ids = malloc(sizeof(uint32_t)*NAL_PIC_PARAM_START_SIZE);
|
||||||
if (new->ids == NULL)
|
if (new->ids == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Unable to allocate array within 'dictionary'"
|
fprint_err("### Unable to allocate array within 'dictionary'"
|
||||||
" datastructure\n");
|
" datastructure\n");
|
||||||
free(new);
|
free(new);
|
||||||
return 1;
|
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);
|
new->params = malloc(SIZEOF_NAL_INNARDS*NAL_PIC_PARAM_START_SIZE);
|
||||||
if (new->params == NULL)
|
if (new->params == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Unable to allocate array within 'dictionary'"
|
fprint_err("### Unable to allocate array within 'dictionary'"
|
||||||
" datastructure\n");
|
" datastructure\n");
|
||||||
free(new->ids);
|
free(new->ids);
|
||||||
free(new);
|
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);
|
new->posns = malloc(SIZEOF_ES_OFFSET*NAL_PIC_PARAM_START_SIZE);
|
||||||
if (new->posns == NULL)
|
if (new->posns == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Unable to allocate array within 'dictionary'"
|
fprint_err("### Unable to allocate array within 'dictionary'"
|
||||||
" datastructure\n");
|
" datastructure\n");
|
||||||
free(new->params);
|
free(new->params);
|
||||||
free(new->ids);
|
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);
|
new->data_lens = malloc(sizeof(uint32_t)*NAL_PIC_PARAM_START_SIZE);
|
||||||
if (new->data_lens == NULL)
|
if (new->data_lens == NULL)
|
||||||
{
|
{
|
||||||
fprintf(stderr,"### Unable to allocate array within 'dictionary'"
|
fprint_err("### Unable to allocate array within 'dictionary'"
|
||||||
" datastructure\n");
|
" datastructure\n");
|
||||||
free(new->params);
|
free(new->params);
|
||||||
free(new->ids);
|
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));
|
param_dict->ids = realloc(param_dict->ids,newsize*sizeof(uint32_t));
|
||||||
if (param_dict->ids == NULL)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
param_dict->params = realloc(param_dict->params,
|
param_dict->params = realloc(param_dict->params,
|
||||||
newsize*SIZEOF_NAL_INNARDS);
|
newsize*SIZEOF_NAL_INNARDS);
|
||||||
if (param_dict->params == NULL)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
param_dict->posns = realloc(param_dict->params,newsize*SIZEOF_ES_OFFSET);
|
param_dict->posns = realloc(param_dict->params,newsize*SIZEOF_ES_OFFSET);
|
||||||
if (param_dict->posns == NULL)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
param_dict->data_lens = realloc(param_dict->params,
|
param_dict->data_lens = realloc(param_dict->params,
|
||||||
newsize*sizeof(uint32_t));
|
newsize*sizeof(uint32_t));
|
||||||
if (param_dict->data_lens == NULL)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
param_dict->size = newsize;
|
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);
|
int absent = lookup_param_data(pic_param_dict,pic_param_id,&innards);
|
||||||
if (absent)
|
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);
|
pic_param_id);
|
||||||
return 1;
|
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);
|
int absent = lookup_param_data(seq_param_dict,seq_param_id,&innards);
|
||||||
if (absent)
|
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);
|
seq_param_id);
|
||||||
return 1;
|
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);
|
nal_unit_list_p new = malloc(SIZEOF_NAL_UNIT_LIST);
|
||||||
if (new == NULL)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1838,7 +1839,7 @@ extern int build_nal_unit_list(nal_unit_list_p *list)
|
||||||
if (new->array == NULL)
|
if (new->array == NULL)
|
||||||
{
|
{
|
||||||
free(new);
|
free(new);
|
||||||
fprintf(stderr,
|
fprint_err(
|
||||||
"### Unable to allocate array in NAL unit list datastructure\n");
|
"### Unable to allocate array in NAL unit list datastructure\n");
|
||||||
return 1;
|
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));
|
list->array = realloc(list->array,newsize*sizeof(nal_unit_p));
|
||||||
if (list->array == NULL)
|
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;
|
return 1;
|
||||||
}
|
}
|
||||||
list->size = newsize;
|
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.
|
* 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,
|
char *prefix,
|
||||||
nal_unit_list_p list)
|
nal_unit_list_p list)
|
||||||
{
|
{
|
||||||
if (prefix == NULL)
|
if (prefix == NULL)
|
||||||
prefix = "";
|
prefix = "";
|
||||||
if (list->array == NULL)
|
if (list->array == NULL)
|
||||||
fprintf(stream,"%s<empty>\n",prefix);
|
fprint_msg_or_err(is_msg,"%s<empty>\n",prefix);
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
int ii;
|
int ii;
|
||||||
for (ii=0; ii<list->length; ii++)
|
for (ii=0; ii<list->length; ii++)
|
||||||
{
|
{
|
||||||
fprintf(stream,"%s",prefix);
|
fprint_msg_or_err(is_msg,"%s",prefix);
|
||||||
report_nal(stream,list->array[ii]);
|
report_nal(is_msg,list->array[ii]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -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.
|
* 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,
|
char *prefix,
|
||||||
nal_unit_list_p list);
|
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.
|
* 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);
|
nal_unit_p nal);
|
||||||
|
|
||||||
#endif // _nalunit_fns
|
#endif // _nalunit_fns
|
||||||
|
|
|
@ -161,13 +161,13 @@ extern void fprint_err(const char *format, ...)
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Prints the given formatted text, as a normal or error message.
|
* 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_list va_arg;
|
||||||
va_start(va_arg, format);
|
va_start(va_arg, format);
|
||||||
if (normal)
|
if (is_msg)
|
||||||
{
|
{
|
||||||
#if DEBUG
|
#if DEBUG
|
||||||
printf("?m:%p %s",fns.fprint_message_fn,format);
|
printf("?m:%p %s",fns.fprint_message_fn,format);
|
||||||
|
|
|
@ -52,9 +52,9 @@ extern void fprint_msg(const char *format, ...);
|
||||||
extern void fprint_err(const char *format, ...);
|
extern void fprint_err(const char *format, ...);
|
||||||
/*
|
/*
|
||||||
* Prints the given formatted text, as a normal or error message.
|
* 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
|
// Choosing what the printing functions do
|
||||||
|
|
Ładowanie…
Reference in New Issue