annotate raw.c @ 3777:20545fbb6f7c libavcodec

add some #ifdef CONFIG_ENCODERS/DECODERS
author mru
date Wed, 27 Sep 2006 19:54:07 +0000
parents d4ab276e5987
children c8c591fe26f8
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
1 /*
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
2 * Raw Video Codec
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
3 * Copyright (c) 2001 Fabrice Bellard.
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
4 *
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
5 * This library is free software; you can redistribute it and/or
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
6 * modify it under the terms of the GNU Lesser General Public
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
7 * License as published by the Free Software Foundation; either
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
8 * version 2 of the License, or (at your option) any later version.
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
9 *
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
10 * This library is distributed in the hope that it will be useful,
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
13 * Lesser General Public License for more details.
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
14 *
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
15 * You should have received a copy of the GNU Lesser General Public
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
16 * License along with this library; if not, write to the Free Software
3036
0b546eab515d Update licensing information: The FSF changed postal address.
diego
parents: 2979
diff changeset
17 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
18 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2863
diff changeset
19
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
20 /**
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
21 * @file raw.c
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
22 * Raw Video Codec
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
23 */
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2863
diff changeset
24
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
25 #include "avcodec.h"
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
26
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
27 typedef struct RawVideoContext {
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
28 unsigned char * buffer; /* block of memory for holding one frame */
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
29 int length; /* number of bytes in buffer */
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
30 AVFrame pic; ///< AVCodecContext.coded_frame
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
31 } RawVideoContext;
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
32
3077
385e54795a9e Fix silly typos.
diego
parents: 3036
diff changeset
33 typedef struct PixelFormatTag {
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
34 int pix_fmt;
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
35 unsigned int fourcc;
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
36 } PixelFormatTag;
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
37
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
38 const PixelFormatTag pixelFormatTags[] = {
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
39 { PIX_FMT_YUV420P, MKTAG('I', '4', '2', '0') }, /* Planar formats */
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
40 { PIX_FMT_YUV420P, MKTAG('I', 'Y', 'U', 'V') },
3587
d4ab276e5987 Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents: 3306
diff changeset
41 { PIX_FMT_YUV420P, MKTAG('Y', 'V', '1', '2') },
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
42 { PIX_FMT_YUV410P, MKTAG('Y', 'U', 'V', '9') },
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
43 { PIX_FMT_YUV411P, MKTAG('Y', '4', '1', 'B') },
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
44 { PIX_FMT_YUV422P, MKTAG('Y', '4', '2', 'B') },
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
45 { PIX_FMT_GRAY8, MKTAG('Y', '8', '0', '0') },
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
46 { PIX_FMT_GRAY8, MKTAG(' ', ' ', 'Y', '8') },
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
47
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
48
2863
521756176cbb a few more raw yuv fourccs
michael
parents: 2661
diff changeset
49 { PIX_FMT_YUV422, MKTAG('Y', 'U', 'Y', '2') }, /* Packed formats */
521756176cbb a few more raw yuv fourccs
michael
parents: 2661
diff changeset
50 { PIX_FMT_YUV422, MKTAG('Y', '4', '2', '2') },
2142
caacb3f9ee51 Add UYVY support to libavcodec/raw.c patch by ("Todd.Kirby" <doubleshot at pacbell dot net>)
michael
parents: 2133
diff changeset
51 { PIX_FMT_UYVY422, MKTAG('U', 'Y', 'V', 'Y') },
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
52 { PIX_FMT_GRAY8, MKTAG('G', 'R', 'E', 'Y') },
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
53
3306
78963e63a45c add quicktime uncompressed 8bit 4:2:2 support
bcoudurier
parents: 3160
diff changeset
54 /* quicktime */
78963e63a45c add quicktime uncompressed 8bit 4:2:2 support
bcoudurier
parents: 3160
diff changeset
55 { PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') },
78963e63a45c add quicktime uncompressed 8bit 4:2:2 support
bcoudurier
parents: 3160
diff changeset
56
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
57 { -1, 0 },
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
58 };
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
59
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
60 static int findPixelFormat(unsigned int fourcc)
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
61 {
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
62 const PixelFormatTag * tags = pixelFormatTags;
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
63 while (tags->pix_fmt >= 0) {
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
64 if (tags->fourcc == fourcc)
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
65 return tags->pix_fmt;
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
66 tags++;
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
67 }
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
68 return PIX_FMT_YUV420P;
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
69 }
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
70
2341
d9c9b42767da fix image stream copy
michael
parents: 2166
diff changeset
71 unsigned int avcodec_pix_fmt_to_codec_tag(enum PixelFormat fmt)
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
72 {
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
73 const PixelFormatTag * tags = pixelFormatTags;
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
74 while (tags->pix_fmt >= 0) {
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
75 if (tags->pix_fmt == fmt)
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
76 return tags->fourcc;
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
77 tags++;
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
78 }
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
79 return 0;
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
80 }
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
81
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
82 /* RAW Decoder Implementation */
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
83
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
84 static int raw_init_decoder(AVCodecContext *avctx)
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
85 {
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
86 RawVideoContext *context = avctx->priv_data;
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
87
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
88 if (avctx->codec_tag)
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
89 avctx->pix_fmt = findPixelFormat(avctx->codec_tag);
2133
29f774bb85fe raw rgb support
michael
parents: 2028
diff changeset
90 else if (avctx->bits_per_sample){
29f774bb85fe raw rgb support
michael
parents: 2028
diff changeset
91 switch(avctx->bits_per_sample){
3160
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
92 case 8: avctx->pix_fmt= PIX_FMT_PAL8 ; break;
2133
29f774bb85fe raw rgb support
michael
parents: 2028
diff changeset
93 case 15: avctx->pix_fmt= PIX_FMT_RGB555; break;
29f774bb85fe raw rgb support
michael
parents: 2028
diff changeset
94 case 16: avctx->pix_fmt= PIX_FMT_RGB565; break;
29f774bb85fe raw rgb support
michael
parents: 2028
diff changeset
95 case 24: avctx->pix_fmt= PIX_FMT_BGR24 ; break;
29f774bb85fe raw rgb support
michael
parents: 2028
diff changeset
96 case 32: avctx->pix_fmt= PIX_FMT_RGBA32; break;
29f774bb85fe raw rgb support
michael
parents: 2028
diff changeset
97 }
29f774bb85fe raw rgb support
michael
parents: 2028
diff changeset
98 }
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2863
diff changeset
99
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
100 context->length = avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height);
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
101 context->buffer = av_malloc(context->length);
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
102 context->pic.pict_type = FF_I_TYPE;
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
103 context->pic.key_frame = 1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2863
diff changeset
104
1195
f7522f310c7e segfault fix
michaelni
parents: 1155
diff changeset
105 avctx->coded_frame= &context->pic;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2863
diff changeset
106
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
107 if (!context->buffer)
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
108 return -1;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2863
diff changeset
109
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
110 return 0;
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
111 }
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
112
2375
24d3a50d1b8b raw rgb flip fix
michael
parents: 2341
diff changeset
113 static void flip(AVCodecContext *avctx, AVPicture * picture){
3160
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
114 if(!avctx->codec_tag && avctx->bits_per_sample && picture->linesize[2]==0){
2375
24d3a50d1b8b raw rgb flip fix
michael
parents: 2341
diff changeset
115 picture->data[0] += picture->linesize[0] * (avctx->height-1);
24d3a50d1b8b raw rgb flip fix
michael
parents: 2341
diff changeset
116 picture->linesize[0] *= -1;
24d3a50d1b8b raw rgb flip fix
michael
parents: 2341
diff changeset
117 }
24d3a50d1b8b raw rgb flip fix
michael
parents: 2341
diff changeset
118 }
24d3a50d1b8b raw rgb flip fix
michael
parents: 2341
diff changeset
119
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
120 static int raw_decode(AVCodecContext *avctx,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
121 void *data, int *data_size,
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
122 uint8_t *buf, int buf_size)
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
123 {
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
124 RawVideoContext *context = avctx->priv_data;
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
125
3080
16eff725382f Set interlaced_frame and top_field_first according to coded_frame.
diego
parents: 3077
diff changeset
126 AVFrame * frame = (AVFrame *) data;
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
127 AVPicture * picture = (AVPicture *) data;
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
128
3080
16eff725382f Set interlaced_frame and top_field_first according to coded_frame.
diego
parents: 3077
diff changeset
129 frame->interlaced_frame = avctx->coded_frame->interlaced_frame;
16eff725382f Set interlaced_frame and top_field_first according to coded_frame.
diego
parents: 3077
diff changeset
130 frame->top_field_first = avctx->coded_frame->top_field_first;
16eff725382f Set interlaced_frame and top_field_first according to coded_frame.
diego
parents: 3077
diff changeset
131
3160
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
132 if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0))
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
133 return -1;
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
134
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
135 avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height);
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
136 if(avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length){
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
137 frame->data[1]= context->buffer;
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
138 }
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
139 if (avctx->palctrl && avctx->palctrl->palette_changed) {
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
140 memcpy(frame->data[1], avctx->palctrl->palette, AVPALETTE_SIZE);
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
141 avctx->palctrl->palette_changed = 0;
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
142 }
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
143
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2863
diff changeset
144 flip(avctx, picture);
3587
d4ab276e5987 Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents: 3306
diff changeset
145
d4ab276e5987 Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents: 3306
diff changeset
146 if (avctx->codec_tag == MKTAG('Y', 'V', '1', '2'))
d4ab276e5987 Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents: 3306
diff changeset
147 {
d4ab276e5987 Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents: 3306
diff changeset
148 // swap fields
d4ab276e5987 Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents: 3306
diff changeset
149 unsigned char *tmp = picture->data[1];
d4ab276e5987 Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents: 3306
diff changeset
150 picture->data[1] = picture->data[2];
d4ab276e5987 Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents: 3306
diff changeset
151 picture->data[2] = tmp;
d4ab276e5987 Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents: 3306
diff changeset
152 }
d4ab276e5987 Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents: 3306
diff changeset
153
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
154 *data_size = sizeof(AVPicture);
3160
25f6245381be PAL8 support (fixed BLUR8.AVI)
michael
parents: 3080
diff changeset
155 return buf_size;
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
156 }
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
157
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
158 static int raw_close_decoder(AVCodecContext *avctx)
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
159 {
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
160 RawVideoContext *context = avctx->priv_data;
2967
ef2149182f1c COSMETICS: Remove all trailing whitespace.
diego
parents: 2863
diff changeset
161
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
162 av_freep(&context->buffer);
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
163 return 0;
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
164 }
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
165
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
166 /* RAW Encoder Implementation */
3777
20545fbb6f7c add some #ifdef CONFIG_ENCODERS/DECODERS
mru
parents: 3587
diff changeset
167 #ifdef CONFIG_RAWVIDEO_ENCODER
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
168 static int raw_init_encoder(AVCodecContext *avctx)
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
169 {
1266
ec946cb74397 Warning fixes.
mellum
parents: 1231
diff changeset
170 avctx->coded_frame = (AVFrame *)avctx->priv_data;
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
171 avctx->coded_frame->pict_type = FF_I_TYPE;
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
172 avctx->coded_frame->key_frame = 1;
2166
10d28761f78c give the user a chance to override codec_tag
michael
parents: 2142
diff changeset
173 if(!avctx->codec_tag)
2341
d9c9b42767da fix image stream copy
michael
parents: 2166
diff changeset
174 avctx->codec_tag = avcodec_pix_fmt_to_codec_tag(avctx->pix_fmt);
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
175 return 0;
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
176 }
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
177
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
178 static int raw_encode(AVCodecContext *avctx,
2979
bfabfdf9ce55 COSMETICS: tabs --> spaces, some prettyprinting
diego
parents: 2967
diff changeset
179 unsigned char *frame, int buf_size, void *data)
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
180 {
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
181 return avpicture_layout((AVPicture *)data, avctx->pix_fmt, avctx->width,
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
182 avctx->height, frame, buf_size);
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
183 }
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
184
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
185 AVCodec rawvideo_encoder = {
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
186 "rawvideo",
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
187 CODEC_TYPE_VIDEO,
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
188 CODEC_ID_RAWVIDEO,
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
189 sizeof(AVFrame),
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
190 raw_init_encoder,
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
191 raw_encode,
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
192 };
2661
b2846918585c a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents: 2375
diff changeset
193 #endif // CONFIG_RAWVIDEO_ENCODER
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
194
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
195 AVCodec rawvideo_decoder = {
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
196 "rawvideo",
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
197 CODEC_TYPE_VIDEO,
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
198 CODEC_ID_RAWVIDEO,
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
199 sizeof(RawVideoContext),
1231
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
200 raw_init_decoder,
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
201 NULL,
b88dfc4bbf8c * introducing new public interface in imgconvert.c
romansh
parents: 1195
diff changeset
202 raw_close_decoder,
1139
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
203 raw_decode,
6842feb093c1 rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff changeset
204 };