*
* You should have received a copy of the GNU Lesser General Public
* License along with this library; if not, write to the Free Software
- * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*
*/
AVCodecContext *avctx;
DSPContext dsp;
AVFrame frame;
- AVFrame prev_frame;
unsigned char *buf;
int size;
} RpzaContext;
-#define BE_16(x) ((((uint8_t*)(x))[0] << 8) | ((uint8_t*)(x))[1])
-#define BE_32(x) ((((uint8_t*)(x))[0] << 24) | \
- (((uint8_t*)(x))[1] << 16) | \
- (((uint8_t*)(x))[2] << 8) | \
- ((uint8_t*)(x))[3])
-
#define ADVANCE_BLOCK() \
{ \
pixel_ptr += 4; \
unsigned char index, idx;
unsigned short ta, tb;
unsigned short *pixels = (unsigned short *)s->frame.data[0];
- unsigned short *prev_pixels = (unsigned short *)s->prev_frame.data[0];
int row_ptr = 0;
int pixel_ptr = 0;
/* First byte is always 0xe1. Warn if it's different */
if (s->buf[stream_ptr] != 0xe1)
- av_log(s->avctx, AV_LOG_ERROR, "First chunk byte is 0x%02x instead of 0x1e\n",
+ av_log(s->avctx, AV_LOG_ERROR, "First chunk byte is 0x%02x instead of 0xe1\n",
s->buf[stream_ptr]);
/* Get chunk size, ingnoring first byte */
chunk_size = s->size;
/* Number of 4x4 blocks in frame. */
- total_blocks = (s->avctx->width * s->avctx->height) / (4 * 4);
+ total_blocks = ((s->avctx->width + 3) / 4) * ((s->avctx->height + 3) / 4);
/* Process chunk data */
while (stream_ptr < chunk_size) {
colorA = (opcode << 8) | (s->buf[stream_ptr++]);
opcode = 0;
if ((s->buf[stream_ptr] & 0x80) != 0) {
- /* Must behave as opcode 110xxxxx, using colorA computed
- * above. Use fake opcode 0x20 to enter switch block at
+ /* Must behave as opcode 110xxxxx, using colorA computed
+ * above. Use fake opcode 0x20 to enter switch block at
* the right place */
opcode = 0x20;
n_blocks = 1;
/* Skip blocks */
case 0x80:
while (n_blocks--) {
- if (!s->avctx->cr_available) {
- block_ptr = row_ptr + pixel_ptr;
- for (pixel_y = 0; pixel_y < 4; pixel_y++) {
- for (pixel_x = 0; pixel_x < 4; pixel_x++){
- pixels[block_ptr] = prev_pixels[block_ptr];
- block_ptr++;
- }
- block_ptr += row_inc;
- }
- }
ADVANCE_BLOCK();
}
break;
avctx->has_b_frames = 0;
dsputil_init(&s->dsp, avctx);
- s->frame.data[0] = s->prev_frame.data[0] = NULL;
+ s->frame.data[0] = NULL;
return 0;
}
{
RpzaContext *s = (RpzaContext *)avctx->priv_data;
- /* no supplementary picture */
- if (buf_size == 0)
- return 0;
-
s->buf = buf;
s->size = buf_size;
s->frame.reference = 1;
- s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE;
- if (avctx->cr_available)
- s->frame.buffer_hints |= FF_BUFFER_HINTS_REUSABLE;
- else
- s->frame.buffer_hints |= FF_BUFFER_HINTS_READABLE;
- if (avctx->get_buffer(avctx, &s->frame)) {
- av_log(avctx, AV_LOG_ERROR, " RPZA Video: get_buffer() failed\n");
+ s->frame.buffer_hints = FF_BUFFER_HINTS_VALID | FF_BUFFER_HINTS_PRESERVE | FF_BUFFER_HINTS_REUSABLE;
+ if (avctx->reget_buffer(avctx, &s->frame)) {
+ av_log(avctx, AV_LOG_ERROR, "reget_buffer() failed\n");
return -1;
}
- if (s->prev_frame.data[0] &&(s->frame.linesize[0] != s->prev_frame.linesize[0]))
- av_log(avctx, AV_LOG_ERROR, "Buffer linesize changed: current %u, previous %u.\n"
- "Expect wrong image and/or crash!\n",
- s->frame.linesize[0], s->prev_frame.linesize[0]);
-
rpza_decode_stream(s);
- if (s->prev_frame.data[0])
- avctx->release_buffer(avctx, &s->prev_frame);
-
- /* shuffle frames */
- if (!avctx->cr_available)
- s->prev_frame = s->frame;
-
*data_size = sizeof(AVFrame);
*(AVFrame*)data = s->frame;
{
RpzaContext *s = (RpzaContext *)avctx->priv_data;
- if (s->prev_frame.data[0])
- avctx->release_buffer(avctx, &s->prev_frame);
+ if (s->frame.data[0])
+ avctx->release_buffer(avctx, &s->frame);
return 0;
}
NULL,
rpza_decode_end,
rpza_decode_frame,
- CODEC_CAP_DR1 | CODEC_CAP_CR,
+ CODEC_CAP_DR1,
};