diff options
Diffstat (limited to 'gst/mpeg1sys/buffer.c')
-rw-r--r-- | gst/mpeg1sys/buffer.c | 407 |
1 files changed, 222 insertions, 185 deletions
diff --git a/gst/mpeg1sys/buffer.c b/gst/mpeg1sys/buffer.c index 0d029529..ceb67d07 100644 --- a/gst/mpeg1sys/buffer.c +++ b/gst/mpeg1sys/buffer.c @@ -36,7 +36,7 @@ #define AUDIO_SYNCWORD 0xfff -#define CLOCKS 90000.0 +#define CLOCKS 90000.0 #ifdef G_HAVE_ISO_VARARGS @@ -49,26 +49,26 @@ #endif /* This must match decoder and encoder tables */ -static double picture_rates [16] = -{ - 0.0, - 24000.0/1001., - 24.0, - 25.0, - 30000.0/1001., - 30.0, - 50.0, - 60000.0/1001., - 60.0, - - 1, - 5, - 10, - 12, - 15, - 0, - 0 +static double picture_rates[16] = { + 0.0, + 24000.0 / 1001., + 24.0, + 25.0, + 30000.0 / 1001., + 30.0, + 50.0, + 60000.0 / 1001., + 60.0, + + 1, + 5, + 10, + 12, + 15, + 0, + 0 }; + /* defined but not used static double ratio [16] = { 0., 1., 0.6735, 0.7031, 0.7615, 0.8055, 0.8437, 0.8935, 0.9157, 0.9815, 1.0255, 1.0695, 1.0950, 1.1575, @@ -76,26 +76,25 @@ static double ratio [16] = { 0., 1., 0.6735, 0.7031, 0.7615, 0.8055, */ #ifndef GST_DISABLE_GST_DEBUG -static char picture_types [4][3] = - { "I", "P", "B", "D" }; +static char picture_types[4][3] = { "I", "P", "B", "D" }; #endif static int bitrate_index[2][3][16] = -{ { {0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448, }, - {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384, }, - {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, } }, - { {0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256, }, - {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, }, - {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160, } }, + { {{0, 32, 64, 96, 128, 160, 192, 224, 256, 288, 320, 352, 384, 416, 448,}, + {0, 32, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320, 384,}, + {0, 32, 40, 48, 56, 64, 80, 96, 112, 128, 160, 192, 224, 256, 320,}}, +{{0, 32, 48, 56, 64, 80, 96, 112, 128, 144, 160, 176, 192, 224, 256,}, + {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}, + {0, 8, 16, 24, 32, 40, 48, 56, 64, 80, 96, 112, 128, 144, 160,}}, }; static long frequency[9] = -{44100, 48000, 32000, 22050, 24000, 16000, 11025, 12000, 8000}; + { 44100, 48000, 32000, 22050, 24000, 16000, 11025, 12000, 8000 }; + +static double dfrequency[9] = { 44.1, 48, 32, 22.05, 24, 16, 11.025, 12, 8 }; -static double dfrequency[9] = -{44.1, 48, 32, 22.05, 24, 16, 11.025, 12, 8}; +static unsigned int samples[4] = { 192, 384, 1152, 1152 }; -static unsigned int samples [4] = {192, 384, 1152, 1152}; /* deined but not used static char mode [4][15] = { "stereo", "joint stereo", "dual channel", "single channel" }; @@ -106,11 +105,13 @@ static char original [2][10] = static char emphasis [4][20] = { "none", "50/15 microseconds", "reserved", "CCITT J.17" }; */ -static void mpeg1mux_buffer_update_video_info(Mpeg1MuxBuffer *mb); -static void mpeg1mux_buffer_update_audio_info(Mpeg1MuxBuffer *mb); +static void mpeg1mux_buffer_update_video_info (Mpeg1MuxBuffer * mb); +static void mpeg1mux_buffer_update_audio_info (Mpeg1MuxBuffer * mb); -Mpeg1MuxBuffer *mpeg1mux_buffer_new(guchar type, guchar id) { - Mpeg1MuxBuffer *new = g_malloc(sizeof(Mpeg1MuxBuffer)); +Mpeg1MuxBuffer * +mpeg1mux_buffer_new (guchar type, guchar id) +{ + Mpeg1MuxBuffer *new = g_malloc (sizeof (Mpeg1MuxBuffer)); new->buffer = NULL; new->length = 0; @@ -127,47 +128,50 @@ Mpeg1MuxBuffer *mpeg1mux_buffer_new(guchar type, guchar id) { return new; } -void mpeg1mux_buffer_queue(Mpeg1MuxBuffer *mb, GstBuffer *buf) { +void +mpeg1mux_buffer_queue (Mpeg1MuxBuffer * mb, GstBuffer * buf) +{ if (mb->buffer == NULL) { - mb->buffer = g_malloc(GST_BUFFER_SIZE(buf)); - mb->length = GST_BUFFER_SIZE(buf); - memcpy(mb->buffer, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf)); - } - else { - mb->buffer = g_realloc(mb->buffer, mb->length + GST_BUFFER_SIZE(buf)); - memcpy(mb->buffer+mb->length, GST_BUFFER_DATA(buf), GST_BUFFER_SIZE(buf)); - mb->length += GST_BUFFER_SIZE(buf); + mb->buffer = g_malloc (GST_BUFFER_SIZE (buf)); + mb->length = GST_BUFFER_SIZE (buf); + memcpy (mb->buffer, GST_BUFFER_DATA (buf), GST_BUFFER_SIZE (buf)); + } else { + mb->buffer = g_realloc (mb->buffer, mb->length + GST_BUFFER_SIZE (buf)); + memcpy (mb->buffer + mb->length, GST_BUFFER_DATA (buf), + GST_BUFFER_SIZE (buf)); + mb->length += GST_BUFFER_SIZE (buf); } GST_DEBUG ("queuing buffer %lu", mb->length); if (mb->buffer_type == BUFFER_TYPE_VIDEO) { - mpeg1mux_buffer_update_video_info(mb); - } - else { - mpeg1mux_buffer_update_audio_info(mb); + mpeg1mux_buffer_update_video_info (mb); + } else { + mpeg1mux_buffer_update_audio_info (mb); } } -gulong mpeg1mux_buffer_update_queued(Mpeg1MuxBuffer *mb, guint64 scr) { +gulong +mpeg1mux_buffer_update_queued (Mpeg1MuxBuffer * mb, guint64 scr) +{ GList *queued_list; Mpeg1MuxTimecode *tc; gulong total_queued = 0; - + GST_DEBUG ("queued in buffer on SCR=%" G_GUINT64_FORMAT, scr); - queued_list = g_list_first(mb->queued_list); + queued_list = g_list_first (mb->queued_list); while (queued_list) { tc = (Mpeg1MuxTimecode *) queued_list->data; if (tc->DTS < scr) { /* this buffer should be sent out */ - mb->queued_list = g_list_remove(mb->queued_list, tc); - queued_list = g_list_first(mb->queued_list); - } - else { - GST_DEBUG ("queued in buffer %ld, %" G_GUINT64_FORMAT, tc->original_length, tc->DTS); + mb->queued_list = g_list_remove (mb->queued_list, tc); + queued_list = g_list_first (mb->queued_list); + } else { + GST_DEBUG ("queued in buffer %ld, %" G_GUINT64_FORMAT, + tc->original_length, tc->DTS); total_queued += tc->original_length; - queued_list = g_list_next(queued_list); + queued_list = g_list_next (queued_list); } } GST_DEBUG ("queued in buffer %lu", total_queued); @@ -175,7 +179,9 @@ gulong mpeg1mux_buffer_update_queued(Mpeg1MuxBuffer *mb, guint64 scr) { return total_queued; } -void mpeg1mux_buffer_shrink(Mpeg1MuxBuffer *mb, gulong size) { +void +mpeg1mux_buffer_shrink (Mpeg1MuxBuffer * mb, gulong size) +{ GList *timecode_list; Mpeg1MuxTimecode *tc; gulong consumed = 0; @@ -183,35 +189,37 @@ void mpeg1mux_buffer_shrink(Mpeg1MuxBuffer *mb, gulong size) { GST_DEBUG ("shrinking buffer %lu", size); - g_assert(mb->length >= size); + g_assert (mb->length >= size); - memcpy(mb->buffer, mb->buffer+size, mb->length-size); - mb->buffer = g_realloc(mb->buffer, mb->length-size); + memcpy (mb->buffer, mb->buffer + size, mb->length - size); + mb->buffer = g_realloc (mb->buffer, mb->length - size); mb->length -= size; mb->scan_pos -= size; mb->current_start -= size; - timecode_list = g_list_first(mb->timecode_list); + timecode_list = g_list_first (mb->timecode_list); tc = (Mpeg1MuxTimecode *) timecode_list->data; - + if (tc->length > size) { tc->length -= size; mb->new_frame = FALSE; - } - else { + } else { consumed += tc->length; while (size >= consumed) { - GST_DEBUG ("removing timecode: %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT " %lu %lu", tc->DTS, tc->PTS, tc->length, consumed); - mb->timecode_list = g_list_remove_link(mb->timecode_list, timecode_list); - mb->queued_list = g_list_append(mb->queued_list, tc); - timecode_list = g_list_first(mb->timecode_list); + GST_DEBUG ("removing timecode: %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT + " %lu %lu", tc->DTS, tc->PTS, tc->length, consumed); + mb->timecode_list = g_list_remove_link (mb->timecode_list, timecode_list); + mb->queued_list = g_list_append (mb->queued_list, tc); + timecode_list = g_list_first (mb->timecode_list); tc = (Mpeg1MuxTimecode *) timecode_list->data; consumed += tc->length; - GST_DEBUG ("next timecode: %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT " %lu %lu", tc->DTS, tc->PTS, tc->length, consumed); + GST_DEBUG ("next timecode: %" G_GUINT64_FORMAT " %" G_GUINT64_FORMAT + " %lu %lu", tc->DTS, tc->PTS, tc->length, consumed); } mb->new_frame = TRUE; - GST_DEBUG ("leftover frame size from %lu to %lu ", tc->length, consumed-size); + GST_DEBUG ("leftover frame size from %lu to %lu ", tc->length, + consumed - size); tc->length = consumed - size; } @@ -219,128 +227,143 @@ void mpeg1mux_buffer_shrink(Mpeg1MuxBuffer *mb, gulong size) { mb->info.video.DTS = tc->DTS; mb->info.video.PTS = tc->PTS; mb->next_frame_time = tc->DTS; - } - else { + } else { mb->info.audio.PTS = tc->PTS; mb->next_frame_time = tc->PTS; } - GST_DEBUG ("next frame time timecode: %" G_GUINT64_FORMAT " %lu", mb->next_frame_time, tc->length); + GST_DEBUG ("next frame time timecode: %" G_GUINT64_FORMAT " %lu", + mb->next_frame_time, tc->length); /* check buffer consistency */ - timecode_list = g_list_first(mb->timecode_list); + timecode_list = g_list_first (mb->timecode_list); count = 0; while (timecode_list) { tc = (Mpeg1MuxTimecode *) timecode_list->data; count += tc->length; - - timecode_list = g_list_next(timecode_list); + + timecode_list = g_list_next (timecode_list); } - if (count != mb->current_start) g_print("********** error %lu != %lu\n", count, mb->current_start); + if (count != mb->current_start) + g_print ("********** error %lu != %lu\n", count, mb->current_start); mb->base += size; } -static void mpeg1mux_buffer_update_video_info(Mpeg1MuxBuffer *mb) { +static void +mpeg1mux_buffer_update_video_info (Mpeg1MuxBuffer * mb) +{ gboolean have_sync = FALSE; guchar *data = mb->buffer; gulong offset = mb->scan_pos; guint sync_zeros = 0; - gulong id=0; + gulong id = 0; guint temporal_reference, temp; gst_getbits_t gb; - + GST_DEBUG ("mpeg1mux::update_video_info %lu %lu", mb->base, mb->scan_pos); if (mb->base == 0 && mb->scan_pos == 0) { - if ((SYNCWORD_START<<8)+*(mb->buffer+3) == SEQUENCE_HEADER) { - - gst_getbits_init(&gb, NULL, NULL); - gst_getbits_newbuf(&gb, data+4, mb->length); - mb->info.video.horizontal_size = gst_getbits12(&gb); - mb->info.video.vertical_size = gst_getbits12(&gb); - mb->info.video.aspect_ratio = gst_getbits4(&gb); - mb->info.video.picture_rate = gst_getbits4(&gb); - mb->info.video.bit_rate = gst_getbits18(&gb); - if (gst_getbits1(&gb) != 1) { - g_print("mpeg1mux::update_video_info: marker bit error\n"); + if ((SYNCWORD_START << 8) + *(mb->buffer + 3) == SEQUENCE_HEADER) { + + gst_getbits_init (&gb, NULL, NULL); + gst_getbits_newbuf (&gb, data + 4, mb->length); + mb->info.video.horizontal_size = gst_getbits12 (&gb); + mb->info.video.vertical_size = gst_getbits12 (&gb); + mb->info.video.aspect_ratio = gst_getbits4 (&gb); + mb->info.video.picture_rate = gst_getbits4 (&gb); + mb->info.video.bit_rate = gst_getbits18 (&gb); + if (gst_getbits1 (&gb) != 1) { + g_print ("mpeg1mux::update_video_info: marker bit error\n"); } - mb->info.video.vbv_buffer_size = gst_getbits10(&gb); - mb->info.video.CSPF = gst_getbits1(&gb); - - mb->info.video.secs_per_frame = 1. / picture_rates[mb->info.video.picture_rate]; - mb->info.video.decoding_order=0; - mb->info.video.group_order=0; - GST_DEBUG ("mpeg1mux::update_video_info: secs per frame %g", mb->info.video.secs_per_frame); - } - else { - g_print("mpeg1mux::update_video_info: Invalid MPEG Video header\n"); + mb->info.video.vbv_buffer_size = gst_getbits10 (&gb); + mb->info.video.CSPF = gst_getbits1 (&gb); + + mb->info.video.secs_per_frame = + 1. / picture_rates[mb->info.video.picture_rate]; + mb->info.video.decoding_order = 0; + mb->info.video.group_order = 0; + GST_DEBUG ("mpeg1mux::update_video_info: secs per frame %g", + mb->info.video.secs_per_frame); + } else { + g_print ("mpeg1mux::update_video_info: Invalid MPEG Video header\n"); } } - while (offset < mb->length-6) { + while (offset < mb->length - 6) { if (!have_sync) { - guchar byte = *(data+offset); + guchar byte = *(data + offset); + /*GST_DEBUG ("mpeg1mux::update_video_info: found #%d at %lu",byte,offset); */ offset++; /* if it's zero, increment the zero count */ if (byte == 0) { - sync_zeros++; - /*GST_DEBUG ("mpeg1mux::update_video_info: found zero #%d at %lu",sync_zeros,offset-1); */ + sync_zeros++; + /*GST_DEBUG ("mpeg1mux::update_video_info: found zero #%d at %lu",sync_zeros,offset-1); */ } /* if it's a one and we have two previous zeros, we have sync */ else if ((byte == 1) && (sync_zeros >= 2)) { - GST_DEBUG ("mpeg1mux::update_video_info: synced at %lu",offset-1); - have_sync = TRUE; - sync_zeros = 0; + GST_DEBUG ("mpeg1mux::update_video_info: synced at %lu", offset - 1); + have_sync = TRUE; + sync_zeros = 0; } /* if it's anything else, we've lost it completely */ - else sync_zeros = 0; - /* then snag the chunk ID */ + else + sync_zeros = 0; + /* then snag the chunk ID */ } else if (id == 0) { - id = *(data+offset); - GST_DEBUG ("mpeg1mux::update_video_info: got id 0x%02lX",id); - id = (SYNCWORD_START<<8)+id; + id = *(data + offset); + GST_DEBUG ("mpeg1mux::update_video_info: got id 0x%02lX", id); + id = (SYNCWORD_START << 8) + id; switch (id) { case SEQUENCE_HEADER: - GST_DEBUG ("mpeg1mux::update_video_info: sequence header"); + GST_DEBUG ("mpeg1mux::update_video_info: sequence header"); break; case GROUP_START: - GST_DEBUG ("mpeg1mux::update_video_info: group start"); - mb->info.video.group_order=0; + GST_DEBUG ("mpeg1mux::update_video_info: group start"); + mb->info.video.group_order = 0; break; case PICTURE_START: /* skip the first access unit */ if (mb->info.video.decoding_order != 0) { Mpeg1MuxTimecode *tc; - GST_DEBUG ("mpeg1mux::update_video_info: PTS %" G_GUINT64_FORMAT ", DTS %" G_GUINT64_FORMAT ", length %lu", mb->info.video.current_PTS, - mb->info.video.current_DTS, offset - mb->current_start-3); - tc = (Mpeg1MuxTimecode *) g_malloc(sizeof(Mpeg1MuxTimecode)); - tc->length = offset - mb->current_start-3; + GST_DEBUG ("mpeg1mux::update_video_info: PTS %" G_GUINT64_FORMAT + ", DTS %" G_GUINT64_FORMAT ", length %lu", + mb->info.video.current_PTS, mb->info.video.current_DTS, + offset - mb->current_start - 3); + + tc = (Mpeg1MuxTimecode *) g_malloc (sizeof (Mpeg1MuxTimecode)); + tc->length = offset - mb->current_start - 3; tc->original_length = tc->length; tc->frame_type = mb->info.video.current_type; tc->DTS = mb->info.video.current_DTS; tc->PTS = mb->info.video.current_PTS; - mb->timecode_list = g_list_append(mb->timecode_list, tc); + mb->timecode_list = g_list_append (mb->timecode_list, tc); if (mb->info.video.decoding_order == 0) { mb->next_frame_time = tc->DTS; } - mb->current_start = offset-3; + mb->current_start = offset - 3; } - temp= (*(data+offset+1)<<8)+*(data+offset+2); + temp = (*(data + offset + 1) << 8) + *(data + offset + 2); temporal_reference = (temp & 0xffc0) >> 6; mb->info.video.current_type = (temp & 0x0038) >> 3; - GST_DEBUG ("mpeg1mux::update_video_info: picture start temporal_ref:%d type:%s Frame", temporal_reference, - picture_types[mb->info.video.current_type-1]); - - mb->info.video.current_DTS = mb->info.video.decoding_order * mb->info.video.secs_per_frame * CLOCKS; - mb->info.video.current_PTS = (temporal_reference - mb->info.video.group_order + 1 + - mb->info.video.decoding_order) *mb->info.video.secs_per_frame*CLOCKS; + GST_DEBUG + ("mpeg1mux::update_video_info: picture start temporal_ref:%d type:%s Frame", + temporal_reference, + picture_types[mb->info.video.current_type - 1]); + + mb->info.video.current_DTS = + mb->info.video.decoding_order * mb->info.video.secs_per_frame * + CLOCKS; + mb->info.video.current_PTS = + (temporal_reference - mb->info.video.group_order + 1 + + mb->info.video.decoding_order) * mb->info.video.secs_per_frame * + CLOCKS; mb->info.video.decoding_order++; mb->info.video.group_order++; @@ -349,7 +372,7 @@ static void mpeg1mux_buffer_update_video_info(Mpeg1MuxBuffer *mb) { offset++; break; case SEQUENCE_END: - GST_DEBUG ("mpeg1mux::update_video_info: sequence end"); + GST_DEBUG ("mpeg1mux::update_video_info: sequence end"); break; } /* prepare for next sync */ @@ -362,105 +385,115 @@ static void mpeg1mux_buffer_update_video_info(Mpeg1MuxBuffer *mb) { mb->scan_pos = offset; } -static void mpeg1mux_buffer_update_audio_info(Mpeg1MuxBuffer *mb) { +static void +mpeg1mux_buffer_update_audio_info (Mpeg1MuxBuffer * mb) +{ guchar *data = mb->buffer; gulong offset = mb->scan_pos; - guint32 id=0; + guint32 id = 0; guint padding_bit; gst_getbits_t gb; guint startup_delay = 0; - int layer_index,lsf,samplerate_index,padding; + int layer_index, lsf, samplerate_index, padding; long bpf; Mpeg1MuxTimecode *tc; - + GST_DEBUG ("mpeg1mux::update_audio_info %lu %lu", mb->base, mb->scan_pos); if (mb->base == 0 && mb->scan_pos == 0) { - id = GUINT32_FROM_BE(*((guint32 *)(data))); + id = GUINT32_FROM_BE (*((guint32 *) (data))); - printf("MPEG audio id = %08x\n", (unsigned int)id); - if ((id & 0xfff00000) == AUDIO_SYNCWORD<<20) { + printf ("MPEG audio id = %08x\n", (unsigned int) id); + if ((id & 0xfff00000) == AUDIO_SYNCWORD << 20) { /* mpegver = (header >> 19) & 0x3; don't need this for bpf */ layer_index = (id >> 17) & 0x3; mb->info.audio.layer = 4 - layer_index; lsf = (id & (1 << 20)) ? ((id & (1 << 19)) ? 0 : 1) : 1; - mb->info.audio.bit_rate = bitrate_index[lsf][mb->info.audio.layer - 1][((id >> 12) & 0xf)]; + mb->info.audio.bit_rate = + bitrate_index[lsf][mb->info.audio.layer - 1][((id >> 12) & 0xf)]; samplerate_index = (id >> 10) & 0x3; padding = (id >> 9) & 0x1; if (mb->info.audio.layer == 1) { - bpf = mb->info.audio.bit_rate * 12000; - bpf /= frequency[samplerate_index]; - bpf = ((bpf + padding) << 2); + bpf = mb->info.audio.bit_rate * 12000; + bpf /= frequency[samplerate_index]; + bpf = ((bpf + padding) << 2); } else { - bpf = mb->info.audio.bit_rate * 144000; - bpf /= frequency[samplerate_index]; - bpf += padding; + bpf = mb->info.audio.bit_rate * 144000; + bpf /= frequency[samplerate_index]; + bpf += padding; } mb->info.audio.framesize = bpf; - GST_DEBUG ("mpeg1mux::update_audio_info: samples per second %d", samplerate_index); + GST_DEBUG ("mpeg1mux::update_audio_info: samples per second %d", + samplerate_index); - gst_getbits_init(&gb, NULL, NULL); - gst_getbits_newbuf(&gb, data, mb->length); + gst_getbits_init (&gb, NULL, NULL); + gst_getbits_newbuf (&gb, data, mb->length); - gst_flushbitsn(&gb, 12); - if (gst_getbits1(&gb) != 1) { - g_print("mpeg1mux::update_audio_info: marker bit error\n"); + gst_flushbitsn (&gb, 12); + if (gst_getbits1 (&gb) != 1) { + g_print ("mpeg1mux::update_audio_info: marker bit error\n"); } - gst_flushbitsn(&gb, 2); - mb->info.audio.protection = gst_getbits1(&gb); - gst_flushbitsn(&gb, 4); - mb->info.audio.frequency = gst_getbits2(&gb); - padding_bit = gst_getbits1(&gb); - gst_flushbitsn(&gb, 1); - mb->info.audio.mode = gst_getbits2(&gb); - mb->info.audio.mode_extension = gst_getbits2(&gb); - mb->info.audio.copyright = gst_getbits1(&gb); - mb->info.audio.original_copy = gst_getbits1(&gb); - mb->info.audio.emphasis = gst_getbits2(&gb); + gst_flushbitsn (&gb, 2); + mb->info.audio.protection = gst_getbits1 (&gb); + gst_flushbitsn (&gb, 4); + mb->info.audio.frequency = gst_getbits2 (&gb); + padding_bit = gst_getbits1 (&gb); + gst_flushbitsn (&gb, 1); + mb->info.audio.mode = gst_getbits2 (&gb); + mb->info.audio.mode_extension = gst_getbits2 (&gb); + mb->info.audio.copyright = gst_getbits1 (&gb); + mb->info.audio.original_copy = gst_getbits1 (&gb); + mb->info.audio.emphasis = gst_getbits2 (&gb); GST_DEBUG ("mpeg1mux::update_audio_info: layer %d", mb->info.audio.layer); - GST_DEBUG ("mpeg1mux::update_audio_info: bit_rate %d", mb->info.audio.bit_rate); - GST_DEBUG ("mpeg1mux::update_audio_info: frequency %d", mb->info.audio.frequency); + GST_DEBUG ("mpeg1mux::update_audio_info: bit_rate %d", + mb->info.audio.bit_rate); + GST_DEBUG ("mpeg1mux::update_audio_info: frequency %d", + mb->info.audio.frequency); - mb->info.audio.samples_per_second = (double)dfrequency [mb->info.audio.frequency]; + mb->info.audio.samples_per_second = + (double) dfrequency[mb->info.audio.frequency]; - GST_DEBUG ("mpeg1mux::update_audio_info: samples per second %g", mb->info.audio.samples_per_second); + GST_DEBUG ("mpeg1mux::update_audio_info: samples per second %g", + mb->info.audio.samples_per_second); - mb->info.audio.decoding_order=0; + mb->info.audio.decoding_order = 0; - tc = (Mpeg1MuxTimecode *) g_malloc(sizeof(Mpeg1MuxTimecode)); + tc = (Mpeg1MuxTimecode *) g_malloc (sizeof (Mpeg1MuxTimecode)); tc->length = mb->info.audio.framesize; tc->original_length = tc->length; tc->frame_type = FRAME_TYPE_AUDIO; - mb->info.audio.current_PTS = mb->info.audio.decoding_order * samples [mb->info.audio.layer] / - mb->info.audio.samples_per_second * 90. + startup_delay; + mb->info.audio.current_PTS = + mb->info.audio.decoding_order * samples[mb->info.audio.layer] / + mb->info.audio.samples_per_second * 90. + startup_delay; - GST_DEBUG ("mpeg1mux::update_audio_info: PTS %" G_GUINT64_FORMAT ", length %u", mb->info.audio.current_PTS, mb->info.audio.framesize); + GST_DEBUG ("mpeg1mux::update_audio_info: PTS %" G_GUINT64_FORMAT + ", length %u", mb->info.audio.current_PTS, mb->info.audio.framesize); tc->PTS = mb->info.audio.current_PTS; tc->DTS = mb->info.audio.current_PTS; - mb->timecode_list = g_list_append(mb->timecode_list, tc); + mb->timecode_list = g_list_append (mb->timecode_list, tc); mb->next_frame_time = tc->PTS; mb->info.audio.decoding_order++; offset += tc->length; - } - else { - g_print("mpeg1mux::update_audio_info: Invalid MPEG Video header\n"); + } else { + g_print ("mpeg1mux::update_audio_info: Invalid MPEG Video header\n"); } } - while (offset < mb->length-4) { - id = GUINT32_FROM_BE(*((guint32 *)(data+offset))); + while (offset < mb->length - 4) { + id = GUINT32_FROM_BE (*((guint32 *) (data + offset))); /* mpegver = (header >> 19) & 0x3; don't need this for bpf */ layer_index = (id >> 17) & 0x3; mb->info.audio.layer = 4 - layer_index; lsf = (id & (1 << 20)) ? ((id & (1 << 19)) ? 0 : 1) : 1; - mb->info.audio.bit_rate = bitrate_index[lsf][mb->info.audio.layer - 1][((id >> 12) & 0xf)]; + mb->info.audio.bit_rate = + bitrate_index[lsf][mb->info.audio.layer - 1][((id >> 12) & 0xf)]; samplerate_index = (id >> 10) & 0x3; padding = (id >> 9) & 0x1; @@ -473,21 +506,25 @@ static void mpeg1mux_buffer_update_audio_info(Mpeg1MuxBuffer *mb) { bpf /= frequency[samplerate_index]; bpf += padding; } - tc = (Mpeg1MuxTimecode *) g_malloc(sizeof(Mpeg1MuxTimecode)); + tc = (Mpeg1MuxTimecode *) g_malloc (sizeof (Mpeg1MuxTimecode)); tc->length = bpf; tc->original_length = tc->length; tc->frame_type = FRAME_TYPE_AUDIO; mb->current_start = offset + bpf; - mb->info.audio.samples_per_second = (double)dfrequency [mb->info.audio.frequency]; + mb->info.audio.samples_per_second = + (double) dfrequency[mb->info.audio.frequency]; - mb->info.audio.current_PTS = (mb->info.audio.decoding_order * samples [mb->info.audio.layer]) / - mb->info.audio.samples_per_second * 90. ; + mb->info.audio.current_PTS = + (mb->info.audio.decoding_order * samples[mb->info.audio.layer]) / + mb->info.audio.samples_per_second * 90.; tc->DTS = tc->PTS = mb->info.audio.current_PTS; - GST_DEBUG ("mpeg1mux::update_audio_info: PTS %" G_GUINT64_FORMAT ", %" G_GUINT64_FORMAT " length %lu", mb->info.audio.current_PTS, tc->PTS, tc->length); - mb->timecode_list = g_list_append(mb->timecode_list, tc); + GST_DEBUG ("mpeg1mux::update_audio_info: PTS %" G_GUINT64_FORMAT ", %" + G_GUINT64_FORMAT " length %lu", mb->info.audio.current_PTS, tc->PTS, + tc->length); + mb->timecode_list = g_list_append (mb->timecode_list, tc); mb->info.audio.decoding_order++; offset += tc->length; |