annotate ffmpeg/libavcodec/v308dec.c @ 13:844d341cf643 tip

Back up before ISMIR
author Yading Song <yading.song@eecs.qmul.ac.uk>
date Thu, 31 Oct 2013 13:17:06 +0000
parents 6840f77b83aa
children
rev   line source
yading@10 1 /*
yading@10 2 * v308 decoder
yading@10 3 * Copyright (c) 2011 Carl Eugen Hoyos
yading@10 4 *
yading@10 5 * This file is part of FFmpeg.
yading@10 6 *
yading@10 7 * FFmpeg is free software; you can redistribute it and/or
yading@10 8 * modify it under the terms of the GNU Lesser General Public
yading@10 9 * License as published by the Free Software Foundation; either
yading@10 10 * version 2.1 of the License, or (at your option) any later version.
yading@10 11 *
yading@10 12 * FFmpeg is distributed in the hope that it will be useful,
yading@10 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
yading@10 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
yading@10 15 * Lesser General Public License for more details.
yading@10 16 *
yading@10 17 * You should have received a copy of the GNU Lesser General Public
yading@10 18 * License along with FFmpeg; if not, write to the Free Software
yading@10 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
yading@10 20 */
yading@10 21
yading@10 22 #include "avcodec.h"
yading@10 23 #include "internal.h"
yading@10 24
yading@10 25 static av_cold int v308_decode_init(AVCodecContext *avctx)
yading@10 26 {
yading@10 27 avctx->pix_fmt = AV_PIX_FMT_YUV444P;
yading@10 28
yading@10 29 if (avctx->width & 1)
yading@10 30 av_log(avctx, AV_LOG_WARNING, "v308 requires width to be even.\n");
yading@10 31
yading@10 32 return 0;
yading@10 33 }
yading@10 34
yading@10 35 static int v308_decode_frame(AVCodecContext *avctx, void *data,
yading@10 36 int *got_frame, AVPacket *avpkt)
yading@10 37 {
yading@10 38 AVFrame *pic = data;
yading@10 39 const uint8_t *src = avpkt->data;
yading@10 40 uint8_t *y, *u, *v;
yading@10 41 int i, j, ret;
yading@10 42
yading@10 43 if (avpkt->size < 3 * avctx->height * avctx->width) {
yading@10 44 av_log(avctx, AV_LOG_ERROR, "Insufficient input data.\n");
yading@10 45 return AVERROR(EINVAL);
yading@10 46 }
yading@10 47
yading@10 48 if ((ret = ff_get_buffer(avctx, pic, 0)) < 0)
yading@10 49 return ret;
yading@10 50
yading@10 51 pic->key_frame = 1;
yading@10 52 pic->pict_type = AV_PICTURE_TYPE_I;
yading@10 53
yading@10 54 y = pic->data[0];
yading@10 55 u = pic->data[1];
yading@10 56 v = pic->data[2];
yading@10 57
yading@10 58 for (i = 0; i < avctx->height; i++) {
yading@10 59 for (j = 0; j < avctx->width; j++) {
yading@10 60 v[j] = *src++;
yading@10 61 y[j] = *src++;
yading@10 62 u[j] = *src++;
yading@10 63 }
yading@10 64
yading@10 65 y += pic->linesize[0];
yading@10 66 u += pic->linesize[1];
yading@10 67 v += pic->linesize[2];
yading@10 68 }
yading@10 69
yading@10 70 *got_frame = 1;
yading@10 71
yading@10 72 return avpkt->size;
yading@10 73 }
yading@10 74
yading@10 75 AVCodec ff_v308_decoder = {
yading@10 76 .name = "v308",
yading@10 77 .type = AVMEDIA_TYPE_VIDEO,
yading@10 78 .id = AV_CODEC_ID_V308,
yading@10 79 .init = v308_decode_init,
yading@10 80 .decode = v308_decode_frame,
yading@10 81 .capabilities = CODEC_CAP_DR1,
yading@10 82 .long_name = NULL_IF_CONFIG_SMALL("Uncompressed packed 4:4:4"),
yading@10 83 };