#include "avcodec.h"
#include "imgconvert.h"
#include "raw.h"
+#include "libavutil/avassert.h"
#include "libavutil/intreadwrite.h"
#include "libavutil/imgutils.h"
#include "libavutil/opt.h"
{"top", "top field first", offsetof(RawVideoContext, tff), AV_OPT_TYPE_INT, {.dbl = -1}, -1, 1, AV_OPT_FLAG_DECODING_PARAM|AV_OPT_FLAG_VIDEO_PARAM},
{NULL}
};
-static const AVClass class = { "rawdec", NULL, options, LIBAVUTIL_VERSION_INT };
+
+static const AVClass class = {
+ .class_name = "rawdec",
+ .option = options,
+ .version = LIBAVUTIL_VERSION_INT,
+};
static const PixelFormatTag pix_fmt_bps_avi[] = {
{ PIX_FMT_MONOWHITE, 1 },
{
RawVideoContext *context = avctx->priv_data;
- if (avctx->codec_tag == MKTAG('r','a','w',' '))
+ if (avctx->codec_tag == MKTAG('r','a','w',' ') || avctx->codec_tag == MKTAG('N','O','1','6'))
avctx->pix_fmt = ff_find_pix_fmt(pix_fmt_bps_mov, avctx->bits_per_coded_sample);
else if (avctx->codec_tag == MKTAG('W','R','A','W'))
avctx->pix_fmt = ff_find_pix_fmt(pix_fmt_bps_avi, avctx->bits_per_coded_sample);
context->length = avpicture_get_size(avctx->pix_fmt, FFALIGN(avctx->width, 16), avctx->height);
context->buffer = av_malloc(context->length);
if (!context->buffer)
- return -1;
+ return AVERROR(ENOMEM);
} else {
context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
}
int buf_size = avpkt->size;
int linesize_align = 4;
RawVideoContext *context = avctx->priv_data;
- int res;
+ int res, len;
AVFrame *frame = data;
AVPicture *picture = data;
frame->reordered_opaque = avctx->reordered_opaque;
frame->pkt_pts = avctx->pkt->pts;
frame->pkt_pos = avctx->pkt->pos;
+ frame->pkt_duration = avctx->pkt->duration;
if(context->tff>=0){
frame->interlaced_frame = 1;
if (context->buffer) {
int i;
uint8_t *dst = context->buffer;
- buf_size = context->length - 256*4;
+ buf_size = context->length - AVPALETTE_SIZE;
if (avctx->bits_per_coded_sample == 4){
for(i=0; 2*i+1 < buf_size && i<avpkt->size; i++){
dst[2*i+0]= buf[i]>>4;
}
linesize_align = 8;
} else {
+ av_assert0(avctx->bits_per_coded_sample == 2);
for(i=0; 4*i+3 < buf_size && i<avpkt->size; i++){
dst[4*i+0]= buf[i]>>6;
dst[4*i+1]= buf[i]>>4&3;
avctx->codec_tag == MKTAG('A', 'V', 'u', 'p'))
buf += buf_size - context->length;
- if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0))
- return -1;
+ len = context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? AVPALETTE_SIZE : 0);
+ if (buf_size < len) {
+ av_log(avctx, AV_LOG_ERROR, "Invalid buffer size, packet size %d < expected length %d\n", buf_size, len);
+ return AVERROR(EINVAL);
+ }
if ((res = avpicture_fill(picture, buf, avctx->pix_fmt,
avctx->width, avctx->height)) < 0)
line += picture->linesize[0];
}
}
+ if(avctx->codec_tag == AV_RL32("YVYU") &&
+ avctx->pix_fmt == PIX_FMT_YUYV422) {
+ int x, y;
+ uint8_t *line = picture->data[0];
+ for(y = 0; y < avctx->height; y++) {
+ for(x = 0; x < avctx->width - 1; x += 2)
+ FFSWAP(uint8_t, line[2*x + 1], line[2*x + 3]);
+ line += picture->linesize[0];
+ }
+ }
*data_size = sizeof(AVPicture);
return buf_size;