Mercurial > libavcodec.hg
comparison parser.c @ 3082:d85afa120256 libavcodec
output last ac3 frame and simplify
| author | michael |
|---|---|
| date | Thu, 02 Feb 2006 18:38:47 +0000 |
| parents | f02d0b59279c |
| children | befacb1cb573 |
comparison
equal
deleted
inserted
replaced
| 3081:4bf348f8e2b1 | 3082:d85afa120256 |
|---|---|
| 871 buf_ptr = buf; | 871 buf_ptr = buf; |
| 872 while (buf_size > 0) { | 872 while (buf_size > 0) { |
| 873 len = s->inbuf_ptr - s->inbuf; | 873 len = s->inbuf_ptr - s->inbuf; |
| 874 if (s->frame_size == 0) { | 874 if (s->frame_size == 0) { |
| 875 /* no header seen : find one. We need at least 7 bytes to parse it */ | 875 /* no header seen : find one. We need at least 7 bytes to parse it */ |
| 876 len = AC3_HEADER_SIZE - len; | 876 len = FFMIN(AC3_HEADER_SIZE - len, buf_size); |
| 877 if (len > buf_size) | 877 |
| 878 len = buf_size; | |
| 879 memcpy(s->inbuf_ptr, buf_ptr, len); | 878 memcpy(s->inbuf_ptr, buf_ptr, len); |
| 880 buf_ptr += len; | 879 buf_ptr += len; |
| 881 s->inbuf_ptr += len; | 880 s->inbuf_ptr += len; |
| 882 buf_size -= len; | 881 buf_size -= len; |
| 883 if ((s->inbuf_ptr - s->inbuf) == AC3_HEADER_SIZE) { | 882 if ((s->inbuf_ptr - s->inbuf) == AC3_HEADER_SIZE) { |
| 896 } | 895 } |
| 897 avctx->bit_rate = bit_rate; | 896 avctx->bit_rate = bit_rate; |
| 898 avctx->frame_size = 6 * 256; | 897 avctx->frame_size = 6 * 256; |
| 899 } | 898 } |
| 900 } | 899 } |
| 901 } else if (len < s->frame_size) { | 900 } else { |
| 902 len = s->frame_size - len; | 901 len = FFMIN(s->frame_size - len, buf_size); |
| 903 if (len > buf_size) | |
| 904 len = buf_size; | |
| 905 | 902 |
| 906 memcpy(s->inbuf_ptr, buf_ptr, len); | 903 memcpy(s->inbuf_ptr, buf_ptr, len); |
| 907 buf_ptr += len; | 904 buf_ptr += len; |
| 908 s->inbuf_ptr += len; | 905 s->inbuf_ptr += len; |
| 909 buf_size -= len; | 906 buf_size -= len; |
| 910 } else { | 907 |
| 911 *poutbuf = s->inbuf; | 908 if(s->inbuf_ptr - s->inbuf == s->frame_size){ |
| 912 *poutbuf_size = s->frame_size; | 909 *poutbuf = s->inbuf; |
| 913 s->inbuf_ptr = s->inbuf; | 910 *poutbuf_size = s->frame_size; |
| 914 s->frame_size = 0; | 911 s->inbuf_ptr = s->inbuf; |
| 915 break; | 912 s->frame_size = 0; |
| 913 break; | |
| 914 } | |
| 916 } | 915 } |
| 917 } | 916 } |
| 918 return buf_ptr - buf; | 917 return buf_ptr - buf; |
| 919 } | 918 } |
| 920 | 919 |
