- if(!vidbuf_start) { return AVERROR_NOMEM; }
-
- rle_num_bytes = get_byte(pb);
- vidbuf_start[vidbuf_nbytes++] = rle_num_bytes;
-
- if(rle_num_bytes > 0x80) // rle sequence
- {
- if(block_type == VIDEO_FULL_FRAME_BLOCK) { vidbuf_start[vidbuf_nbytes++] = get_byte(pb); }
- bytes_copied += rle_num_bytes - 0x80;
- }
- else if(rle_num_bytes) // plain sequence
- {
- if(get_buffer(pb, &vidbuf_start[vidbuf_nbytes], rle_num_bytes) != rle_num_bytes)
- return AVERROR_IO;
- vidbuf_nbytes += rle_num_bytes;
- bytes_copied += rle_num_bytes;
+ if(!vidbuf_start)
+ return AVERROR(ENOMEM);
+
+ code = get_byte(pb);
+ vidbuf_start[vidbuf_nbytes++] = code;
+
+ if(code >= 0x80){ // rle sequence
+ if(block_type == VIDEO_I_FRAME)
+ vidbuf_start[vidbuf_nbytes++] = get_byte(pb);
+ } else if(code){ // plain sequence
+ if(get_buffer(pb, &vidbuf_start[vidbuf_nbytes], code) != code)
+ goto fail;
+ vidbuf_nbytes += code;