/src/ffmpeg/libavcodec/v210_template.c
Line | Count | Source |
1 | | /* |
2 | | * Copyright (C) 2009 Michael Niedermayer <michaelni@gmx.at> |
3 | | * Copyright (c) 2009 Baptiste Coudurier <baptiste dot coudurier at gmail dot com> |
4 | | * |
5 | | * This file is part of FFmpeg. |
6 | | * |
7 | | * FFmpeg is free software; you can redistribute it and/or |
8 | | * modify it under the terms of the GNU Lesser General Public |
9 | | * License as published by the Free Software Foundation; either |
10 | | * version 2.1 of the License, or (at your option) any later version. |
11 | | * |
12 | | * FFmpeg is distributed in the hope that it will be useful, |
13 | | * but WITHOUT ANY WARRANTY; without even the implied warranty of |
14 | | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
15 | | * Lesser General Public License for more details. |
16 | | * |
17 | | * You should have received a copy of the GNU Lesser General Public |
18 | | * License along with FFmpeg; if not, write to the Free Software |
19 | | * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
20 | | */ |
21 | | |
22 | | #include "bytestream.h" |
23 | | #include "internal.h" |
24 | | |
25 | | static void RENAME(v210_enc)(AVCodecContext *avctx, |
26 | | uint8_t *dst, const AVFrame *pic) |
27 | 7.19k | { |
28 | 7.19k | V210EncContext *s = avctx->priv_data; |
29 | 7.19k | int aligned_width = ((avctx->width + 47) / 48) * 48; |
30 | 7.19k | int stride = aligned_width * 8 / 3; |
31 | 7.19k | int line_padding = stride - ((avctx->width * 8 + 11) / 12) * 4; |
32 | 7.19k | int h, w; |
33 | 7.19k | const TYPE *y = (const TYPE *)pic->data[0]; |
34 | 7.19k | const TYPE *u = (const TYPE *)pic->data[1]; |
35 | 7.19k | const TYPE *v = (const TYPE *)pic->data[2]; |
36 | 7.19k | const int sample_size = 6 * s->RENAME(sample_factor); |
37 | 7.19k | const int sample_w = avctx->width / sample_size; |
38 | | |
39 | 2.02M | for (h = 0; h < avctx->height; h++) { |
40 | 2.01M | uint32_t val; |
41 | 2.01M | w = sample_w * sample_size; |
42 | 2.01M | s->RENAME(pack_line)(y, u, v, dst, w); |
43 | | |
44 | 2.01M | y += w; |
45 | 2.01M | u += w >> 1; |
46 | 2.01M | v += w >> 1; |
47 | 2.01M | dst += sample_w * 16 * s->RENAME(sample_factor); |
48 | | |
49 | 2.33M | for (; w < avctx->width - 5; w += 6) { |
50 | 320k | WRITE_PIXELS(u, y, v, DEPTH); |
51 | 320k | WRITE_PIXELS(y, u, y, DEPTH); |
52 | 320k | WRITE_PIXELS(v, y, u, DEPTH); |
53 | 320k | WRITE_PIXELS(y, v, y, DEPTH); |
54 | 320k | } |
55 | 2.01M | if (w < avctx->width - 1) { |
56 | 1.95M | WRITE_PIXELS(u, y, v, DEPTH); |
57 | | |
58 | 1.95M | val = CLIP(*y++, DEPTH) << (10-DEPTH); |
59 | 1.95M | if (w == avctx->width - 2) { |
60 | 893k | AV_WL32(dst, val); |
61 | 893k | dst += 4; |
62 | 893k | } |
63 | 1.95M | } |
64 | 2.01M | if (w < avctx->width - 3) { |
65 | 1.05M | val |= (CLIP(*u++, DEPTH) << (20-DEPTH)) | (CLIP(*y++, DEPTH) << (30-DEPTH)); |
66 | 1.05M | AV_WL32(dst, val); |
67 | 1.05M | dst += 4; |
68 | | |
69 | 1.05M | val = CLIP(*v++, DEPTH) << (10-DEPTH) | (CLIP(*y++, DEPTH) << (20-DEPTH)); |
70 | 1.05M | AV_WL32(dst, val); |
71 | 1.05M | dst += 4; |
72 | 1.05M | } |
73 | | |
74 | 2.01M | memset(dst, 0, line_padding); |
75 | 2.01M | dst += line_padding; |
76 | 2.01M | y += pic->linesize[0] / BYTES_PER_PIXEL - avctx->width; |
77 | 2.01M | u += pic->linesize[1] / BYTES_PER_PIXEL - avctx->width / 2; |
78 | 2.01M | v += pic->linesize[2] / BYTES_PER_PIXEL - avctx->width / 2; |
79 | 2.01M | } |
80 | 7.19k | } Line | Count | Source | 27 | 4.46k | { | 28 | 4.46k | V210EncContext *s = avctx->priv_data; | 29 | 4.46k | int aligned_width = ((avctx->width + 47) / 48) * 48; | 30 | 4.46k | int stride = aligned_width * 8 / 3; | 31 | 4.46k | int line_padding = stride - ((avctx->width * 8 + 11) / 12) * 4; | 32 | 4.46k | int h, w; | 33 | 4.46k | const TYPE *y = (const TYPE *)pic->data[0]; | 34 | 4.46k | const TYPE *u = (const TYPE *)pic->data[1]; | 35 | 4.46k | const TYPE *v = (const TYPE *)pic->data[2]; | 36 | 4.46k | const int sample_size = 6 * s->RENAME(sample_factor); | 37 | 4.46k | const int sample_w = avctx->width / sample_size; | 38 | | | 39 | 1.07M | for (h = 0; h < avctx->height; h++) { | 40 | 1.06M | uint32_t val; | 41 | 1.06M | w = sample_w * sample_size; | 42 | 1.06M | s->RENAME(pack_line)(y, u, v, dst, w); | 43 | | | 44 | 1.06M | y += w; | 45 | 1.06M | u += w >> 1; | 46 | 1.06M | v += w >> 1; | 47 | 1.06M | dst += sample_w * 16 * s->RENAME(sample_factor); | 48 | | | 49 | 1.06M | for (; w < avctx->width - 5; w += 6) { | 50 | 0 | WRITE_PIXELS(u, y, v, DEPTH); | 51 | 0 | WRITE_PIXELS(y, u, y, DEPTH); | 52 | 0 | WRITE_PIXELS(v, y, u, DEPTH); | 53 | 0 | WRITE_PIXELS(y, v, y, DEPTH); | 54 | 0 | } | 55 | 1.06M | if (w < avctx->width - 1) { | 56 | 1.06M | WRITE_PIXELS(u, y, v, DEPTH); | 57 | | | 58 | 1.06M | val = CLIP(*y++, DEPTH) << (10-DEPTH); | 59 | 1.06M | if (w == avctx->width - 2) { | 60 | 479k | AV_WL32(dst, val); | 61 | 479k | dst += 4; | 62 | 479k | } | 63 | 1.06M | } | 64 | 1.06M | if (w < avctx->width - 3) { | 65 | 581k | val |= (CLIP(*u++, DEPTH) << (20-DEPTH)) | (CLIP(*y++, DEPTH) << (30-DEPTH)); | 66 | 581k | AV_WL32(dst, val); | 67 | 581k | dst += 4; | 68 | | | 69 | 581k | val = CLIP(*v++, DEPTH) << (10-DEPTH) | (CLIP(*y++, DEPTH) << (20-DEPTH)); | 70 | 581k | AV_WL32(dst, val); | 71 | 581k | dst += 4; | 72 | 581k | } | 73 | | | 74 | 1.06M | memset(dst, 0, line_padding); | 75 | 1.06M | dst += line_padding; | 76 | 1.06M | y += pic->linesize[0] / BYTES_PER_PIXEL - avctx->width; | 77 | 1.06M | u += pic->linesize[1] / BYTES_PER_PIXEL - avctx->width / 2; | 78 | 1.06M | v += pic->linesize[2] / BYTES_PER_PIXEL - avctx->width / 2; | 79 | 1.06M | } | 80 | 4.46k | } |
Line | Count | Source | 27 | 2.72k | { | 28 | 2.72k | V210EncContext *s = avctx->priv_data; | 29 | 2.72k | int aligned_width = ((avctx->width + 47) / 48) * 48; | 30 | 2.72k | int stride = aligned_width * 8 / 3; | 31 | 2.72k | int line_padding = stride - ((avctx->width * 8 + 11) / 12) * 4; | 32 | 2.72k | int h, w; | 33 | 2.72k | const TYPE *y = (const TYPE *)pic->data[0]; | 34 | 2.72k | const TYPE *u = (const TYPE *)pic->data[1]; | 35 | 2.72k | const TYPE *v = (const TYPE *)pic->data[2]; | 36 | 2.72k | const int sample_size = 6 * s->RENAME(sample_factor); | 37 | 2.72k | const int sample_w = avctx->width / sample_size; | 38 | | | 39 | 952k | for (h = 0; h < avctx->height; h++) { | 40 | 949k | uint32_t val; | 41 | 949k | w = sample_w * sample_size; | 42 | 949k | s->RENAME(pack_line)(y, u, v, dst, w); | 43 | | | 44 | 949k | y += w; | 45 | 949k | u += w >> 1; | 46 | 949k | v += w >> 1; | 47 | 949k | dst += sample_w * 16 * s->RENAME(sample_factor); | 48 | | | 49 | 1.27M | for (; w < avctx->width - 5; w += 6) { | 50 | 320k | WRITE_PIXELS(u, y, v, DEPTH); | 51 | 320k | WRITE_PIXELS(y, u, y, DEPTH); | 52 | 320k | WRITE_PIXELS(v, y, u, DEPTH); | 53 | 320k | WRITE_PIXELS(y, v, y, DEPTH); | 54 | 320k | } | 55 | 949k | if (w < avctx->width - 1) { | 56 | 890k | WRITE_PIXELS(u, y, v, DEPTH); | 57 | | | 58 | 890k | val = CLIP(*y++, DEPTH) << (10-DEPTH); | 59 | 890k | if (w == avctx->width - 2) { | 60 | 413k | AV_WL32(dst, val); | 61 | 413k | dst += 4; | 62 | 413k | } | 63 | 890k | } | 64 | 949k | if (w < avctx->width - 3) { | 65 | 477k | val |= (CLIP(*u++, DEPTH) << (20-DEPTH)) | (CLIP(*y++, DEPTH) << (30-DEPTH)); | 66 | 477k | AV_WL32(dst, val); | 67 | 477k | dst += 4; | 68 | | | 69 | 477k | val = CLIP(*v++, DEPTH) << (10-DEPTH) | (CLIP(*y++, DEPTH) << (20-DEPTH)); | 70 | 477k | AV_WL32(dst, val); | 71 | 477k | dst += 4; | 72 | 477k | } | 73 | | | 74 | 949k | memset(dst, 0, line_padding); | 75 | 949k | dst += line_padding; | 76 | 949k | y += pic->linesize[0] / BYTES_PER_PIXEL - avctx->width; | 77 | 949k | u += pic->linesize[1] / BYTES_PER_PIXEL - avctx->width / 2; | 78 | 949k | v += pic->linesize[2] / BYTES_PER_PIXEL - avctx->width / 2; | 79 | 949k | } | 80 | 2.72k | } |
|