Mercurial > libavcodec.hg
annotate raw.c @ 4082:f72cc635cce9 libavcodec
adds missing rgb/bgr 555 codec->fmt mappings, ok'ed by Michael
| author | reynaldo |
|---|---|
| date | Fri, 27 Oct 2006 19:50:31 +0000 |
| parents | c8c591fe26f8 |
| children | 065ee7dd69ca |
| 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 |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
40 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 |
| 2863 | 51 { PIX_FMT_YUV422, MKTAG('Y', 'U', 'Y', '2') }, /* Packed formats */ |
| 52 { 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
|
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) }, |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
57 |
| 3306 | 58 /* quicktime */ |
| 59 { PIX_FMT_UYVY422, MKTAG('2', 'v', 'u', 'y') }, | |
| 60 | |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
61 { -1, 0 }, |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
62 }; |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
63 |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
64 static int findPixelFormat(unsigned int fourcc) |
|
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 const PixelFormatTag * tags = pixelFormatTags; |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
67 while (tags->pix_fmt >= 0) { |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
68 if (tags->fourcc == fourcc) |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
69 return tags->pix_fmt; |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
70 tags++; |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
71 } |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
72 return PIX_FMT_YUV420P; |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
73 } |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
74 |
| 2341 | 75 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
|
76 { |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
77 const PixelFormatTag * tags = pixelFormatTags; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
78 while (tags->pix_fmt >= 0) { |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
79 if (tags->pix_fmt == fmt) |
| 2979 | 80 return tags->fourcc; |
| 81 tags++; | |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
82 } |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
83 return 0; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
84 } |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
85 |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
86 /* RAW Decoder Implementation */ |
|
1139
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 static int raw_init_decoder(AVCodecContext *avctx) |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
89 { |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
90 RawVideoContext *context = avctx->priv_data; |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
91 |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
92 if (avctx->codec_tag) |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
93 avctx->pix_fmt = findPixelFormat(avctx->codec_tag); |
| 2133 | 94 else if (avctx->bits_per_sample){ |
| 95 switch(avctx->bits_per_sample){ | |
| 3160 | 96 case 8: avctx->pix_fmt= PIX_FMT_PAL8 ; break; |
| 2133 | 97 case 15: avctx->pix_fmt= PIX_FMT_RGB555; break; |
| 98 case 16: avctx->pix_fmt= PIX_FMT_RGB565; break; | |
| 99 case 24: avctx->pix_fmt= PIX_FMT_BGR24 ; break; | |
| 100 case 32: avctx->pix_fmt= PIX_FMT_RGBA32; break; | |
| 101 } | |
| 102 } | |
| 2967 | 103 |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
104 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
|
105 context->buffer = av_malloc(context->length); |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
106 context->pic.pict_type = FF_I_TYPE; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
107 context->pic.key_frame = 1; |
| 2967 | 108 |
| 1195 | 109 avctx->coded_frame= &context->pic; |
| 2967 | 110 |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
111 if (!context->buffer) |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
112 return -1; |
| 2967 | 113 |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
114 return 0; |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
115 } |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
116 |
| 2375 | 117 static void flip(AVCodecContext *avctx, AVPicture * picture){ |
| 3160 | 118 if(!avctx->codec_tag && avctx->bits_per_sample && picture->linesize[2]==0){ |
| 2375 | 119 picture->data[0] += picture->linesize[0] * (avctx->height-1); |
| 120 picture->linesize[0] *= -1; | |
| 121 } | |
| 122 } | |
| 123 | |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
124 static int raw_decode(AVCodecContext *avctx, |
| 2979 | 125 void *data, int *data_size, |
| 126 uint8_t *buf, int buf_size) | |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
127 { |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
128 RawVideoContext *context = avctx->priv_data; |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
129 |
|
3080
16eff725382f
Set interlaced_frame and top_field_first according to coded_frame.
diego
parents:
3077
diff
changeset
|
130 AVFrame * frame = (AVFrame *) data; |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
131 AVPicture * picture = (AVPicture *) data; |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
132 |
|
3080
16eff725382f
Set interlaced_frame and top_field_first according to coded_frame.
diego
parents:
3077
diff
changeset
|
133 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
|
134 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
|
135 |
| 3160 | 136 if(buf_size < context->length - (avctx->pix_fmt==PIX_FMT_PAL8 ? 256*4 : 0)) |
| 137 return -1; | |
| 138 | |
| 139 avpicture_fill(picture, buf, avctx->pix_fmt, avctx->width, avctx->height); | |
| 140 if(avctx->pix_fmt==PIX_FMT_PAL8 && buf_size < context->length){ | |
| 141 frame->data[1]= context->buffer; | |
| 142 } | |
| 143 if (avctx->palctrl && avctx->palctrl->palette_changed) { | |
| 144 memcpy(frame->data[1], avctx->palctrl->palette, AVPALETTE_SIZE); | |
| 145 avctx->palctrl->palette_changed = 0; | |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
146 } |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
147 |
| 2967 | 148 flip(avctx, picture); |
|
3587
d4ab276e5987
Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents:
3306
diff
changeset
|
149 |
|
d4ab276e5987
Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents:
3306
diff
changeset
|
150 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
|
151 { |
|
d4ab276e5987
Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents:
3306
diff
changeset
|
152 // swap fields |
|
d4ab276e5987
Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents:
3306
diff
changeset
|
153 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
|
154 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
|
155 picture->data[2] = tmp; |
|
d4ab276e5987
Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents:
3306
diff
changeset
|
156 } |
|
d4ab276e5987
Add YV12 support, patch by Steve Lhomme % steve P lhomme A free P fr %
gpoirier
parents:
3306
diff
changeset
|
157 |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
158 *data_size = sizeof(AVPicture); |
| 3160 | 159 return buf_size; |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
160 } |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
161 |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
162 static int raw_close_decoder(AVCodecContext *avctx) |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
163 { |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
164 RawVideoContext *context = avctx->priv_data; |
| 2967 | 165 |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
166 av_freep(&context->buffer); |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
167 return 0; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
168 } |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
169 |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
170 /* RAW Encoder Implementation */ |
| 3777 | 171 #ifdef CONFIG_RAWVIDEO_ENCODER |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
172 static int raw_init_encoder(AVCodecContext *avctx) |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
173 { |
| 1266 | 174 avctx->coded_frame = (AVFrame *)avctx->priv_data; |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
175 avctx->coded_frame->pict_type = FF_I_TYPE; |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
176 avctx->coded_frame->key_frame = 1; |
| 2166 | 177 if(!avctx->codec_tag) |
| 2341 | 178 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
|
179 return 0; |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
180 } |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
181 |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
182 static int raw_encode(AVCodecContext *avctx, |
| 2979 | 183 unsigned char *frame, int buf_size, void *data) |
|
1139
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 return avpicture_layout((AVPicture *)data, avctx->pix_fmt, avctx->width, |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
186 avctx->height, frame, buf_size); |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
187 } |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
188 |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
189 AVCodec rawvideo_encoder = { |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
190 "rawvideo", |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
191 CODEC_TYPE_VIDEO, |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
192 CODEC_ID_RAWVIDEO, |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
193 sizeof(AVFrame), |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
194 raw_init_encoder, |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
195 raw_encode, |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
196 }; |
|
2661
b2846918585c
a few #ifdef CONFIG_X_ENCODER, patch by (Roine Gustafsson <roine users.sourceforge net]
michael
parents:
2375
diff
changeset
|
197 #endif // CONFIG_RAWVIDEO_ENCODER |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
198 |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
199 AVCodec rawvideo_decoder = { |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
200 "rawvideo", |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
201 CODEC_TYPE_VIDEO, |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
202 CODEC_ID_RAWVIDEO, |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
203 sizeof(RawVideoContext), |
|
1231
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
204 raw_init_decoder, |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
205 NULL, |
|
b88dfc4bbf8c
* introducing new public interface in imgconvert.c
romansh
parents:
1195
diff
changeset
|
206 raw_close_decoder, |
|
1139
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
207 raw_decode, |
|
6842feb093c1
rawvideo patch by (Fred Rothganger <rothgang at uiuc dot edu>)
michaelni
parents:
diff
changeset
|
208 }; |
