Line |
Branch |
Exec |
Source |
1 |
|
|
/* |
2 |
|
|
* v408 encoder |
3 |
|
|
* |
4 |
|
|
* Copyright (c) 2012 Carl Eugen Hoyos |
5 |
|
|
* |
6 |
|
|
* This file is part of FFmpeg. |
7 |
|
|
* |
8 |
|
|
* FFmpeg is free software; you can redistribute it and/or |
9 |
|
|
* modify it under the terms of the GNU Lesser General Public |
10 |
|
|
* License as published by the Free Software Foundation; either |
11 |
|
|
* version 2.1 of the License, or (at your option) any later version. |
12 |
|
|
* |
13 |
|
|
* FFmpeg is distributed in the hope that it will be useful, |
14 |
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
15 |
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
16 |
|
|
* Lesser General Public License for more details. |
17 |
|
|
* |
18 |
|
|
* You should have received a copy of the GNU Lesser General Public |
19 |
|
|
* License along with FFmpeg; if not, write to the Free Software |
20 |
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
21 |
|
|
*/ |
22 |
|
|
|
23 |
|
|
#include "avcodec.h" |
24 |
|
|
#include "codec_internal.h" |
25 |
|
|
#include "encode.h" |
26 |
|
|
#include "internal.h" |
27 |
|
|
|
28 |
|
✗ |
static av_cold int v408_encode_init(AVCodecContext *avctx) |
29 |
|
|
{ |
30 |
|
✗ |
avctx->bits_per_coded_sample = 32; |
31 |
|
✗ |
avctx->bit_rate = ff_guess_coded_bitrate(avctx); |
32 |
|
|
|
33 |
|
✗ |
av_log(avctx, AV_LOG_WARNING, "This encoder is deprecated and will be removed.\n"); |
34 |
|
|
|
35 |
|
✗ |
return 0; |
36 |
|
|
} |
37 |
|
|
|
38 |
|
✗ |
static int v408_encode_frame(AVCodecContext *avctx, AVPacket *pkt, |
39 |
|
|
const AVFrame *pic, int *got_packet) |
40 |
|
|
{ |
41 |
|
|
uint8_t *dst; |
42 |
|
|
const uint8_t *y, *u, *v, *a; |
43 |
|
|
int i, j, ret; |
44 |
|
|
|
45 |
|
✗ |
ret = ff_get_encode_buffer(avctx, pkt, avctx->width * avctx->height * 4, 0); |
46 |
|
✗ |
if (ret < 0) |
47 |
|
✗ |
return ret; |
48 |
|
✗ |
dst = pkt->data; |
49 |
|
|
|
50 |
|
✗ |
y = pic->data[0]; |
51 |
|
✗ |
u = pic->data[1]; |
52 |
|
✗ |
v = pic->data[2]; |
53 |
|
✗ |
a = pic->data[3]; |
54 |
|
|
|
55 |
|
✗ |
for (i = 0; i < avctx->height; i++) { |
56 |
|
✗ |
for (j = 0; j < avctx->width; j++) { |
57 |
|
✗ |
*dst++ = u[j]; |
58 |
|
✗ |
*dst++ = y[j]; |
59 |
|
✗ |
*dst++ = v[j]; |
60 |
|
✗ |
*dst++ = a[j]; |
61 |
|
|
} |
62 |
|
✗ |
y += pic->linesize[0]; |
63 |
|
✗ |
u += pic->linesize[1]; |
64 |
|
✗ |
v += pic->linesize[2]; |
65 |
|
✗ |
a += pic->linesize[3]; |
66 |
|
|
} |
67 |
|
|
|
68 |
|
✗ |
*got_packet = 1; |
69 |
|
✗ |
return 0; |
70 |
|
|
} |
71 |
|
|
|
72 |
|
|
static const enum AVPixelFormat pix_fmt[] = { AV_PIX_FMT_YUVA444P, AV_PIX_FMT_NONE }; |
73 |
|
|
|
74 |
|
|
const FFCodec ff_v408_encoder = { |
75 |
|
|
.p.name = "v408", |
76 |
|
|
CODEC_LONG_NAME("Uncompressed packed QT 4:4:4:4"), |
77 |
|
|
.p.type = AVMEDIA_TYPE_VIDEO, |
78 |
|
|
.p.id = AV_CODEC_ID_V408, |
79 |
|
|
.p.capabilities = AV_CODEC_CAP_DR1 | AV_CODEC_CAP_ENCODER_REORDERED_OPAQUE, |
80 |
|
|
.init = v408_encode_init, |
81 |
|
|
FF_CODEC_ENCODE_CB(v408_encode_frame), |
82 |
|
|
.p.pix_fmts = pix_fmt, |
83 |
|
|
}; |
84 |
|
|
|