Mercurial > libavcodec.hg
annotate pamenc.c @ 12043:f9a0bd0888a4 libavcodec
mpegaudio: call ff_mpegaudiodec_init_mmx() only from float decoder
The mmx code is floating-point only, and this function does not know
from which decoder it is called. Without this change, the integer
decoder only "works" because the size of the context struct is smaller
in this case, and the mmx init function writes the function pointer
outside the allocated context.
author | mru |
---|---|
date | Thu, 01 Jul 2010 23:21:17 +0000 |
parents | 8a4984c5cacc |
children |
rev | line source |
---|---|
2344 | 1 /* |
10466 | 2 * PAM image format |
8629
04423b2f6e0b
cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents:
8590
diff
changeset
|
3 * Copyright (c) 2002, 2003 Fabrice Bellard |
2344 | 4 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3455
diff
changeset
|
5 * This file is part of FFmpeg. |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3455
diff
changeset
|
6 * |
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3455
diff
changeset
|
7 * FFmpeg is free software; you can redistribute it and/or |
2344 | 8 * modify it under the terms of the GNU Lesser General Public |
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:
3455
diff
changeset
|
10 * version 2.1 of the License, or (at your option) any later version. |
2344 | 11 * |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3455
diff
changeset
|
12 * FFmpeg is distributed in the hope that it will be useful, |
2344 | 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 | |
3947
c8c591fe26f8
Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents:
3455
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:
2967
diff
changeset
|
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA |
2344 | 20 */ |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
21 |
2344 | 22 #include "avcodec.h" |
5089 | 23 #include "bytestream.h" |
4978 | 24 #include "pnm.h" |
2967 | 25 |
2344 | 26 |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
27 static int pam_encode_frame(AVCodecContext *avctx, unsigned char *outbuf, |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
28 int buf_size, void *data) |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
29 { |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
30 PNMContext *s = avctx->priv_data; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
31 AVFrame *pict = data; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
32 AVFrame * const p = (AVFrame*)&s->picture; |
2344 | 33 int i, h, w, n, linesize, depth, maxval; |
34 const char *tuple_type; | |
35 uint8_t *ptr; | |
36 | |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
37 if (buf_size < avpicture_get_size(avctx->pix_fmt, avctx->width, avctx->height) + 200) { |
2422 | 38 av_log(avctx, AV_LOG_ERROR, "encoded frame too large\n"); |
39 return -1; | |
40 } | |
41 | |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
42 *p = *pict; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
43 p->pict_type = FF_I_TYPE; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
44 p->key_frame = 1; |
2967 | 45 |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
46 s->bytestream_start = |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
47 s->bytestream = outbuf; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
48 s->bytestream_end = outbuf+buf_size; |
2344 | 49 |
50 h = avctx->height; | |
51 w = avctx->width; | |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
52 switch (avctx->pix_fmt) { |
2344 | 53 case PIX_FMT_MONOWHITE: |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
54 n = (w + 7) >> 3; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
55 depth = 1; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
56 maxval = 1; |
2344 | 57 tuple_type = "BLACKANDWHITE"; |
58 break; | |
59 case PIX_FMT_GRAY8: | |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
60 n = w; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
61 depth = 1; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
62 maxval = 255; |
2344 | 63 tuple_type = "GRAYSCALE"; |
64 break; | |
65 case PIX_FMT_RGB24: | |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
66 n = w * 3; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
67 depth = 3; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
68 maxval = 255; |
2344 | 69 tuple_type = "RGB"; |
70 break; | |
4494
ce643a22f049
Replace deprecated PIX_FMT names by the newer variants.
diego
parents:
4152
diff
changeset
|
71 case PIX_FMT_RGB32: |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
72 n = w * 4; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
73 depth = 4; |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
74 maxval = 255; |
2344 | 75 tuple_type = "RGB_ALPHA"; |
76 break; | |
77 default: | |
78 return -1; | |
79 } | |
2967 | 80 snprintf(s->bytestream, s->bytestream_end - s->bytestream, |
2344 | 81 "P7\nWIDTH %d\nHEIGHT %d\nDEPTH %d\nMAXVAL %d\nTUPLETYPE %s\nENDHDR\n", |
82 w, h, depth, maxval, tuple_type); | |
83 s->bytestream += strlen(s->bytestream); | |
2967 | 84 |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
85 ptr = p->data[0]; |
2344 | 86 linesize = p->linesize[0]; |
2967 | 87 |
4494
ce643a22f049
Replace deprecated PIX_FMT names by the newer variants.
diego
parents:
4152
diff
changeset
|
88 if (avctx->pix_fmt == PIX_FMT_RGB32) { |
2344 | 89 int j; |
90 unsigned int v; | |
91 | |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
92 for (i = 0; i < h; i++) { |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
93 for (j = 0; j < w; j++) { |
2344 | 94 v = ((uint32_t *)ptr)[j]; |
5089 | 95 bytestream_put_be24(&s->bytestream, v); |
2344 | 96 *s->bytestream++ = v >> 24; |
97 } | |
98 ptr += linesize; | |
99 } | |
100 } else { | |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
101 for (i = 0; i < h; i++) { |
2344 | 102 memcpy(s->bytestream, ptr, n); |
103 s->bytestream += n; | |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
104 ptr += linesize; |
2344 | 105 } |
106 } | |
107 return s->bytestream - s->bytestream_start; | |
108 } | |
109 | |
2348 | 110 |
2344 | 111 AVCodec pam_encoder = { |
112 "pam", | |
11560
8a4984c5cacc
Define AVMediaType enum, and use it instead of enum CodecType, which
stefano
parents:
10466
diff
changeset
|
113 AVMEDIA_TYPE_VIDEO, |
2344 | 114 CODEC_ID_PAM, |
115 sizeof(PNMContext), | |
10460
059265d3cc65
Move PNM init/end functions to the PNM common code.
diego
parents:
10459
diff
changeset
|
116 ff_pnm_init, |
2344 | 117 pam_encode_frame, |
10459
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
118 .pix_fmts = (const enum PixelFormat[]){PIX_FMT_RGB24, PIX_FMT_RGB32, PIX_FMT_GRAY8, PIX_FMT_MONOWHITE, PIX_FMT_NONE}, |
a6bb56636f90
whitespace cosmetics: K&R coding style, prettyprinting
diego
parents:
10458
diff
changeset
|
119 .long_name = NULL_IF_CONFIG_SMALL("PAM (Portable AnyMap) image"), |
2344 | 120 }; |