* Quicktime Video (RPZA) Video Decoder
* Copyright (C) 2003 the ffmpeg project
*
- * This library is free software; you can redistribute it and/or
+ * This file is part of FFmpeg.
+ *
+ * FFmpeg is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
- * version 2 of the License, or (at your option) any later version.
+ * version 2.1 of the License, or (at your option) any later version.
*
- * This library is distributed in the hope that it will be useful,
+ * FFmpeg is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* 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
- *
+ * License along with FFmpeg; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
/**
#include <string.h>
#include <unistd.h>
-#include "common.h"
#include "avcodec.h"
#include "dsputil.h"
} 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; \
/* 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 = BE_32(&s->buf[stream_ptr]) & 0x00FFFFFF;
+ chunk_size = AV_RB32(&s->buf[stream_ptr]) & 0x00FFFFFF;
stream_ptr += 4;
/* If length mismatch use size from MOV file and try to decode anyway */
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;
/* Fill blocks with one color */
case 0xa0:
- colorA = BE_16 (&s->buf[stream_ptr]);
+ colorA = AV_RB16 (&s->buf[stream_ptr]);
stream_ptr += 2;
while (n_blocks--) {
block_ptr = row_ptr + pixel_ptr;
/* Fill blocks with 4 colors */
case 0xc0:
- colorA = BE_16 (&s->buf[stream_ptr]);
+ colorA = AV_RB16 (&s->buf[stream_ptr]);
stream_ptr += 2;
case 0x20:
- colorB = BE_16 (&s->buf[stream_ptr]);
+ colorB = AV_RB16 (&s->buf[stream_ptr]);
stream_ptr += 2;
/* sort out the colors */
for (pixel_x = 0; pixel_x < 4; pixel_x++){
/* We already have color of upper left pixel */
if ((pixel_y != 0) || (pixel_x !=0)) {
- colorA = BE_16 (&s->buf[stream_ptr]);
+ colorA = AV_RB16 (&s->buf[stream_ptr]);
stream_ptr += 2;
}
pixels[block_ptr] = colorA;
static int rpza_decode_init(AVCodecContext *avctx)
{
- RpzaContext *s = (RpzaContext *)avctx->priv_data;
+ RpzaContext *s = avctx->priv_data;
s->avctx = avctx;
avctx->pix_fmt = PIX_FMT_RGB555;
- avctx->has_b_frames = 0;
dsputil_init(&s->dsp, avctx);
s->frame.data[0] = NULL;
void *data, int *data_size,
uint8_t *buf, int buf_size)
{
- RpzaContext *s = (RpzaContext *)avctx->priv_data;
-
- /* no supplementary picture */
- if (buf_size == 0)
- return 0;
+ RpzaContext *s = avctx->priv_data;
s->buf = buf;
s->size = buf_size;
static int rpza_decode_end(AVCodecContext *avctx)
{
- RpzaContext *s = (RpzaContext *)avctx->priv_data;
+ RpzaContext *s = avctx->priv_data;
if (s->frame.data[0])
avctx->release_buffer(avctx, &s->frame);