Mercurial > libavcodec.hg
annotate raw.c @ 4777:536588c41db6 libavcodec
typo
author | michael |
---|---|
date | Tue, 03 Apr 2007 13:53:25 +0000 |
parents | 9358bf66a1d0 |
children | 334a964f6fc1 |
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 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3777
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3777
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3777
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
8 * 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
|
9 * License as published by the Free Software Foundation; either |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3777
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3777
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
13 * 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
|
14 * 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
|
15 * Lesser General Public License for more details. |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
16 * |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
17 * You should have received a copy of the GNU Lesser General Public |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3777
diff
changeset
|
18 * License along with FFmpeg; if not, write to the Free Software |
3036
0b546eab515d
Update licensing information: The FSF changed postal address.
diego
parents:
2979
diff
changeset
|
19 * 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
|
20 */ |
2967 | 21 |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
22 /** |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
23 * @file raw.c |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
24 * Raw Video Codec |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
25 */ |
2967 | 26 |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
27 #include "avcodec.h" |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
28 |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
29 typedef struct RawVideoContext { |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
30 unsigned char * buffer; /* block of memory for holding one frame */ |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
31 int length; /* number of bytes in buffer */ |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
32 AVFrame pic; ///< AVCodecContext.coded_frame |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
33 } RawVideoContext; |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
34 |
3077 | 35 typedef struct PixelFormatTag { |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
36 int pix_fmt; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
37 unsigned int fourcc; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
38 } PixelFormatTag; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
39 |
4170 | 40 static const PixelFormatTag pixelFormatTags[] = { |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
41 { PIX_FMT_YUV420P, MKTAG('I', '4', '2', '0') }, /* Planar formats */ |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
42 { 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
|
43 { PIX_FMT_YUV420P, MKTAG('Y', 'V', '1', '2') }, |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
44 { PIX_FMT_YUV410P, MKTAG('Y', 'U', 'V', '9') }, |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
45 { PIX_FMT_YUV411P, MKTAG('Y', '4', '1', 'B') }, |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
46 { PIX_FMT_YUV422P, MKTAG('Y', '4', '2', 'B') }, |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
47 { PIX_FMT_GRAY8, MKTAG('Y', '8', '0', '0') }, |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
48 { PIX_FMT_GRAY8, MKTAG(' ', ' ', 'Y', '8') }, |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
49 |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
50 |
4494
ce643a22f049
Replace deprecated PIX_FMT names by the newer variants.
diego
parents:
4170
diff
changeset
|
51 { PIX_FMT_YUYV422, MKTAG('Y', 'U', 'Y', '2') }, /* Packed formats */ |
ce643a22f049
Replace deprecated PIX_FMT names by the newer variants.
diego
parents:
4170
diff
changeset
|
52 { PIX_FMT_YUYV422, 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
|
53 { PIX_FMT_UYVY422, MKTAG('U', 'Y', 'V', 'Y') }, |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
54 { PIX_FMT_GRAY8, MKTAG('G', 'R', 'E', 'Y') }, |
4082
f72cc635cce9
adds missing rgb/bgr 555 codec->fmt mappings, ok'ed by Michael
reynaldo
parents:
3947
diff
changeset
|
55 { PIX_FMT_RGB555, MKTAG('R', 'G', 'B', 15) }, |
f72cc635cce9
adds missing rgb/bgr 555 codec->fmt mappings, ok'ed by Michael
reynaldo
parents:
3947
diff
changeset
|
56 { PIX_FMT_BGR555, MKTAG('B', 'G', 'R', 15) }, |
4083
065ee7dd69ca
adds missing rgb/bgr 565 codec->fmt mappings, ok'ed by Michael
reynaldo
parents:
4082
diff
changeset
|
57 { PIX_FMT_RGB565, MKTAG('R', 'G', 'B', 16) }, |
065ee7dd69ca
adds missing rgb/bgr 565 codec->fmt mappings, ok'ed by Michael
reynaldo
parents:
4082
diff
changeset
|
58 { PIX_FMT_BGR565, MKTAG('B', 'G', 'R', 16) }, |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
59 |
3306 | 60 /* quicktime */ |
61 { PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') }, | |
4619 | 62 { PIX_FMT_UYVY422, MKTAG('A', 'V', 'U', 'I') }, /* FIXME merge both fields */ |
3306 | 63 |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
64 { -1, 0 }, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
65 }; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
66 |
4611 | 67 static const PixelFormatTag pixelFormatBpsAVI[] = { |
68 { PIX_FMT_PAL8, 8 }, | |
69 { PIX_FMT_RGB555, 15 }, | |
70 { PIX_FMT_RGB555, 16 }, | |
71 { PIX_FMT_BGR24, 24 }, | |
72 { PIX_FMT_RGB32, 32 }, | |
73 { -1, 0 }, | |
74 }; | |
75 | |
76 static const PixelFormatTag pixelFormatBpsMOV[] = { | |
77 /* FIXME fix swscaler to support those */ | |
78 /* http://developer.apple.com/documentation/QuickTime/QTFF/QTFFChap3/chapter_4_section_2.html */ | |
79 { PIX_FMT_PAL8, 8 }, | |
80 { PIX_FMT_BGR555, 16 }, | |
81 { PIX_FMT_RGB24, 24 }, | |
82 { PIX_FMT_BGR32_1, 32 }, | |
83 { -1, 0 }, | |
84 }; | |
85 | |
86 static int findPixelFormat(const PixelFormatTag *tags, unsigned int fourcc) | |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
87 { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
88 while (tags->pix_fmt >= 0) { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
89 if (tags->fourcc == fourcc) |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
90 return tags->pix_fmt; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
91 tags++; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
92 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
93 return PIX_FMT_YUV420P; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
94 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
95 |
2341 | 96 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
|
97 { |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
98 const PixelFormatTag * tags = pixelFormatTags; |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
99 while (tags->pix_fmt >= 0) { |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
100 if (tags->pix_fmt == fmt) |
2979 | 101 return tags->fourcc; |
102 tags++; | |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
103 } |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
104 return 0; |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
105 } |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
106 |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
107 /* RAW Decoder Implementation */ |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
108 |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
109 static int raw_init_decoder(AVCodecContext *avctx) |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
110 { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
111 RawVideoContext *context = avctx->priv_data; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
112 |
4611 | 113 if (avctx->codec_tag == MKTAG('r','a','w',' ')) |
114 avctx->pix_fmt = findPixelFormat(pixelFormatBpsMOV, avctx->bits_per_sample); | |
115 else if (avctx->codec_tag) | |
116 avctx->pix_fmt = findPixelFormat(pixelFormatTags, avctx->codec_tag); | |
117 else if (avctx->bits_per_sample) | |
118 avctx->pix_fmt = findPixelFormat(pixelFormatBpsAVI, avctx->bits_per_sample); | |
2967 | 119 |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
120 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
|
121 context->buffer = av_malloc(context->length); |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
122 context->pic.pict_type = FF_I_TYPE; |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
123 context->pic.key_frame = 1; |
2967 | 124 |
1195 | 125 avctx->coded_frame= &context->pic; |
2967 | 126 |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
127 if (!context->buffer) |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
128 return -1; |
2967 | 129 |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
130 return 0; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
131 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
132 |
2375 | 133 static void flip(AVCodecContext *avctx, AVPicture * picture){ |
3160 | 134 if(!avctx->codec_tag && avctx->bits_per_sample && picture->linesize[2]==0){ |
2375 | 135 picture->data[0] += picture->linesize[0] * (avctx->height-1); |
136 picture->linesize[0] *= -1; | |
137 } | |
138 } | |
139 | |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
140 static int raw_decode(AVCodecContext *avctx, |
2979 | 141 void *data, int *data_size, |
142 uint8_t *buf, int buf_size) | |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
143 { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
144 RawVideoContext *context = avctx->priv_data; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
145 |
3080
16eff725382f
Set interlaced_frame and top_field_first according to coded_frame.
diego
parents:
3077
diff
changeset
|
146 AVFrame * frame = (AVFrame *) data; |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
147 AVPicture * picture = (AVPicture *) data; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
148 |
3080
16eff725382f
Set interlaced_frame and top_field_first according to coded_frame.
diego
parents:
3077
diff
changeset
|
149 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
|
150 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
|
151 |
3160 | 152 if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0)) |
153 return -1; | |
154 | |
155 avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height); | |
156 if(avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length){ | |
157 frame->data[1]= context->buffer; | |
158 } | |
159 if (avctx->palctrl && avctx->palctrl->palette_changed) { | |
160 memcpy(frame->data[1], avctx->palctrl->palette, AVPALETTE_SIZE); | |
161 avctx->palctrl->palette_changed = 0; | |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
162 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
163 |
2967 | 164 flip(avctx, picture); |
3587
d4ab276e5987
Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents:
3306
diff
changeset
|
165 |
d4ab276e5987
Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents:
3306
diff
changeset
|
166 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
|
167 { |
d4ab276e5987
Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents:
3306
diff
changeset
|
168 // swap fields |
d4ab276e5987
Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents:
3306
diff
changeset
|
169 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
|
170 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
|
171 picture->data[2] = tmp; |
d4ab276e5987
Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents:
3306
diff
changeset
|
172 } |
d4ab276e5987
Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents:
3306
diff
changeset
|
173 |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
174 *data_size = sizeof(AVPicture); |
3160 | 175 return buf_size; |
1139
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 |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
178 static int raw_close_decoder(AVCodecContext *avctx) |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
179 { |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
180 RawVideoContext *context = avctx->priv_data; |
2967 | 181 |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
182 av_freep(&context->buffer); |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
183 return 0; |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
184 } |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
185 |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
186 /* RAW Encoder Implementation */ |
3777 | 187 #ifdef CONFIG_RAWVIDEO_ENCODER |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
188 static int raw_init_encoder(AVCodecContext *avctx) |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
189 { |
1266 | 190 avctx->coded_frame = (AVFrame *)avctx->priv_data; |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
191 avctx->coded_frame->pict_type = FF_I_TYPE; |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
192 avctx->coded_frame->key_frame = 1; |
2166 | 193 if(!avctx->codec_tag) |
2341 | 194 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
|
195 return 0; |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
196 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
197 |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
198 static int raw_encode(AVCodecContext *avctx, |
2979 | 199 unsigned char *frame, int buf_size, void *data) |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
200 { |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
201 return avpicture_layout((AVPicture *)data, avctx->pix_fmt, avctx->width, |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
202 avctx->height, frame, buf_size); |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
203 } |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
204 |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
205 AVCodec rawvideo_encoder = { |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
206 "rawvideo", |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
207 CODEC_TYPE_VIDEO, |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
208 CODEC_ID_RAWVIDEO, |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
209 sizeof(AVFrame), |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
210 raw_init_encoder, |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
211 raw_encode, |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
212 }; |
2661
b2846918585c
a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents:
2375
diff
changeset
|
213 #endif // CONFIG_RAWVIDEO_ENCODER |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
214 |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
215 AVCodec rawvideo_decoder = { |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
216 "rawvideo", |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
217 CODEC_TYPE_VIDEO, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
218 CODEC_ID_RAWVIDEO, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
219 sizeof(RawVideoContext), |
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
220 raw_init_decoder, |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
221 NULL, |
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
222 raw_close_decoder, |
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
223 raw_decode, |
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
224 }; |