On Tue, Feb 04, 2014 at 11:31:35AM +0100, Anton Khirnov wrote:
> ---
> libavcodec/rpza.c | 58
> ++++++++++++++++++++---------------------------------
> 1 file changed, 22 insertions(+), 36 deletions(-)
>
> diff --git a/libavcodec/rpza.c b/libavcodec/rpza.c
> index 70d145e..6d9778d 100644
> --- a/libavcodec/rpza.c
> +++ b/libavcodec/rpza.c
> @@ -91,34 +88,31 @@ static void rpza_decode_stream(RpzaContext *s)
> int total_blocks;
>
> /* First byte is always 0xe1. Warn if it's different */
> - if (s->buf[stream_ptr] != 0xe1)
> + if (bytestream2_peek_byte(&s->gb) != 0xe1)
> av_log(s->avctx, AV_LOG_ERROR, "First chunk byte is 0x%02x instead
> of 0xe1\n",
> - s->buf[stream_ptr]);
> + bytestream2_peek_byte(&s->gb));
>
> /* Get chunk size, ingnoring first byte */
> - chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF;
> - stream_ptr += 4;
> + chunk_size = bytestream2_get_be32(&s->gb) & 0x00FFFFFF;
>
> /* If length mismatch use size from MOV file and try to decode anyway */
> - if (chunk_size != s->size)
> + if (chunk_size != bytestream2_get_bytes_left(&s->gb) - 4)
> av_log(s->avctx, AV_LOG_ERROR, "MOV chunk size != encoded chunk
> size; using MOV chunk size\n");
does that message make sense anymore?
> - chunk_size = s->size;
> -
> /* Number of 4x4 blocks in frame. */
> - total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) /
> 4);
> + total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 4) /
> 4);
wrong change (and FFALIGN would be better)
>
> /* Process chunk data */
> - while (stream_ptr < chunk_size) {
> - opcode = s->buf[stream_ptr++]; /* Get opcode */
> + while (bytestream2_get_bytes_left(&s->gb)) {
> + opcode = bytestream2_get_byte(&s->gb); /* Get opcode */
>
> n_blocks = (opcode & 0x1f) + 1; /* Extract block counter from opcode
> */
>
> /* If opcode MSbit is 0, we need more data to decide what to do */
> if ((opcode & 0x80) == 0) {
> - colorA = (opcode << 8) | (s->buf[stream_ptr++]);
> + colorA = (opcode << 8) | (bytestream2_get_byte(&s->gb));
second pair of parentheses is completely uncalled for
> opcode = 0;
> - if ((s->buf[stream_ptr] & 0x80) != 0) {
> + if ((bytestream2_peek_byte(&s->gb) & 0x80) != 0) {
> /* Must behave as opcode 110xxxxx, using colorA computed
> * above. Use fake opcode 0x20 to enter switch block at
> * the right place */
the rest looks fine to me
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel