amrparse: consider header size in byte <-> time conversions

This commit is contained in:
Mark Nauwelaerts 2009-05-28 13:09:24 +02:00
parent c07be49896
commit 840955c226
2 changed files with 7 additions and 4 deletions

View File

@ -309,12 +309,12 @@ gst_amrparse_parse_header (GstAmrParse * amrparse,
GST_DEBUG_OBJECT (amrparse, "AMR-WB detected"); GST_DEBUG_OBJECT (amrparse, "AMR-WB detected");
amrparse->block_size = block_size_wb; amrparse->block_size = block_size_wb;
amrparse->wide = TRUE; amrparse->wide = TRUE;
*skipsize = 9; *skipsize = amrparse->header = 9;
} else if (!memcmp (data, "#!AMR\n", 6)) { } else if (!memcmp (data, "#!AMR\n", 6)) {
GST_DEBUG_OBJECT (amrparse, "AMR-NB detected"); GST_DEBUG_OBJECT (amrparse, "AMR-NB detected");
amrparse->block_size = block_size_nb; amrparse->block_size = block_size_nb;
amrparse->wide = FALSE; amrparse->wide = FALSE;
*skipsize = 6; *skipsize = amrparse->header = 6;
} else } else
return FALSE; return FALSE;
@ -453,6 +453,7 @@ gst_amrparse_start (GstBaseParse * parse)
amrparse = GST_AMRPARSE (parse); amrparse = GST_AMRPARSE (parse);
GST_DEBUG ("start"); GST_DEBUG ("start");
amrparse->need_header = TRUE; amrparse->need_header = TRUE;
amrparse->header = 0;
amrparse->sync = TRUE; amrparse->sync = TRUE;
amrparse->eos = FALSE; amrparse->eos = FALSE;
amrparse->framecount = 0; amrparse->framecount = 0;
@ -478,6 +479,7 @@ gst_amrparse_stop (GstBaseParse * parse)
amrparse = GST_AMRPARSE (parse); amrparse = GST_AMRPARSE (parse);
GST_DEBUG ("stop"); GST_DEBUG ("stop");
amrparse->need_header = TRUE; amrparse->need_header = TRUE;
amrparse->header = 0;
amrparse->ts = -1; amrparse->ts = -1;
return TRUE; return TRUE;
} }
@ -548,7 +550,7 @@ gst_amrparse_convert (GstBaseParse * parse,
GST_DEBUG ("converting bytes -> time"); GST_DEBUG ("converting bytes -> time");
if (amrparse->framecount) { if (amrparse->framecount) {
*dest_value = AMR_FRAME_DURATION * src_value / bpf; *dest_value = AMR_FRAME_DURATION * (src_value - amrparse->header) / bpf;
GST_DEBUG ("conversion result: %lld ms", *dest_value / GST_MSECOND); GST_DEBUG ("conversion result: %lld ms", *dest_value / GST_MSECOND);
ret = TRUE; ret = TRUE;
} }
@ -557,7 +559,7 @@ gst_amrparse_convert (GstBaseParse * parse,
GST_DEBUG ("converting time -> bytes"); GST_DEBUG ("converting time -> bytes");
if (dest_format == GST_FORMAT_BYTES) { if (dest_format == GST_FORMAT_BYTES) {
if (amrparse->framecount) { if (amrparse->framecount) {
*dest_value = bpf * src_value / AMR_FRAME_DURATION; *dest_value = bpf * src_value / AMR_FRAME_DURATION + amrparse->header;
GST_DEBUG ("time %lld ms in bytes = %lld", GST_DEBUG ("time %lld ms in bytes = %lld",
src_value / GST_MSECOND, *dest_value); src_value / GST_MSECOND, *dest_value);
ret = TRUE; ret = TRUE;

View File

@ -61,6 +61,7 @@ struct _GstAmrParse {
GstBaseParse element; GstBaseParse element;
const gint *block_size; const gint *block_size;
gboolean need_header; gboolean need_header;
gint header;
gboolean wide; gboolean wide;
gboolean eos; gboolean eos;
gboolean sync; gboolean sync;