annotate mtv.c @ 5770:20ed96c29062 libavformat

av_find_stream_info(): Add a workaround for backwards compatible HE-AAC signaling. The sample rate, frame size, and channel count from the container are not reliable when backwards compatible signaling is used.
author alexc
date Mon, 08 Mar 2010 00:00:50 +0000
parents 0f6f55a8e878
children 536e5527c1e0
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
1 /*
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
2 * mtv demuxer
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
3 * Copyright (c) 2006 Reynaldo H. Verdejo Pinochet
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
4 *
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
5 * This file is part of FFmpeg.
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
6 *
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
11 *
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
15 * Lesser General Public License for more details.
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
16 *
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
20 */
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
21
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
22 /**
4331
49c1d3b27727 Use full internal pathname in doxygen @file directives.
diego
parents: 4069
diff changeset
23 * @file libavformat/mtv.c
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
24 * MTV demuxer.
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
25 */
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
26
3286
6f61c3b36632 Use full path for #includes from another directory.
diego
parents: 3278
diff changeset
27 #include "libavutil/bswap.h"
5302
9d7f3a448c3c Smarten mtv's probe a bit. Check for non zero
reynaldo
parents: 5144
diff changeset
28 #include "libavutil/intreadwrite.h"
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
29 #include "avformat.h"
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
30
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
31 #define MTV_ASUBCHUNK_DATA_SIZE 500
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
32 #define MTV_HEADER_SIZE 512
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
33 #define MTV_AUDIO_PADDING_SIZE 12
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
34 #define AUDIO_SAMPLING_RATE 44100
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
35 #define VIDEO_SID 0
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
36 #define AUDIO_SID 1
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
37
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
38 typedef struct MTVDemuxContext {
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
39
4069
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
40 unsigned int file_size; ///< filesize, not always right
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
41 unsigned int segments; ///< number of 512 byte segments
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
42 unsigned int audio_identifier; ///< 'MP3' on all files I have seen
5344
b596cf9ab248 Corrects two typos
reynaldo
parents: 5343
diff changeset
43 unsigned int audio_br; ///< bitrate of audio channel (mp3)
4069
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
44 unsigned int img_colorfmt; ///< frame colorfmt rgb 565/555
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
45 unsigned int img_bpp; ///< frame bits per pixel
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
46 unsigned int img_width; //
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
47 unsigned int img_height; //
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
48 unsigned int img_segment_size; ///< size of image segment
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
49 unsigned int video_fps; //
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
50 unsigned int full_segment_size;
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
51
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
52 } MTVDemuxContext;
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
53
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
54 static int mtv_probe(AVProbeData *p)
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
55 {
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
56 /* Magic is 'AMV' */
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
57 if(*(p->buf) != 'A' || *(p->buf+1) != 'M' || *(p->buf+2) != 'V')
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
58 return 0;
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
59
5302
9d7f3a448c3c Smarten mtv's probe a bit. Check for non zero
reynaldo
parents: 5144
diff changeset
60 /* Check for nonzero in bpp and (width|height) header fields */
9d7f3a448c3c Smarten mtv's probe a bit. Check for non zero
reynaldo
parents: 5144
diff changeset
61 if(!(p->buf[51] && AV_RL16(&p->buf[52]) | AV_RL16(&p->buf[54])))
9d7f3a448c3c Smarten mtv's probe a bit. Check for non zero
reynaldo
parents: 5144
diff changeset
62 return 0;
9d7f3a448c3c Smarten mtv's probe a bit. Check for non zero
reynaldo
parents: 5144
diff changeset
63
5309
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
64 /* If width or height are 0 then imagesize header field should not */
5310
7e2ae4853d3d Fix wrong comparison in r20304
reynaldo
parents: 5309
diff changeset
65 if(!AV_RL16(&p->buf[52]) || !AV_RL16(&p->buf[54]))
5309
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
66 {
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
67 if(!!AV_RL16(&p->buf[56]))
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
68 return AVPROBE_SCORE_MAX/2;
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
69 else
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
70 return 0;
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
71 }
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
72
5343
932ea4344b75 Decrement probe score at unsuported bpp
reynaldo
parents: 5310
diff changeset
73 if(p->buf[51] != 16)
5344
b596cf9ab248 Corrects two typos
reynaldo
parents: 5343
diff changeset
74 return AVPROBE_SCORE_MAX/4; // But we are going to assume 16bpp anyway ..
5343
932ea4344b75 Decrement probe score at unsuported bpp
reynaldo
parents: 5310
diff changeset
75
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
76 return AVPROBE_SCORE_MAX;
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
77 }
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
78
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
79 static int mtv_read_header(AVFormatContext *s, AVFormatParameters *ap)
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
80 {
4069
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
81 MTVDemuxContext *mtv = s->priv_data;
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
82 ByteIOContext *pb = s->pb;
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
83 AVStream *st;
52a514815c9a COSMETICS
reynaldo
parents: 4043
diff changeset
84 unsigned int audio_subsegments;
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
85
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
86 url_fskip(pb, 3);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
87 mtv->file_size = get_le32(pb);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
88 mtv->segments = get_le32(pb);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
89 url_fskip(pb, 32);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
90 mtv->audio_identifier = get_le24(pb);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
91 mtv->audio_br = get_le16(pb);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
92 mtv->img_colorfmt = get_le24(pb);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
93 mtv->img_bpp = get_byte(pb);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
94 mtv->img_width = get_le16(pb);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
95 mtv->img_height = get_le16(pb);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
96 mtv->img_segment_size = get_le16(pb);
5309
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
97
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
98 /* Calculate width and height if missing from header */
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
99
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
100 if(!mtv->img_width)
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
101 mtv->img_width=mtv->img_segment_size / (mtv->img_bpp>>3)
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
102 / mtv->img_height;
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
103
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
104 if(!mtv->img_height)
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
105 mtv->img_height=mtv->img_segment_size / (mtv->img_bpp>>3)
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
106 / mtv->img_width;
a011470132ca If missing, calculate width or height from bpp and
reynaldo
parents: 5302
diff changeset
107
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
108 url_fskip(pb, 4);
3532
a741556d452c Change mtv_read_packet so it does not break after seeking (displaying a shifted image).
reimar
parents: 3531
diff changeset
109 audio_subsegments = get_le16(pb);
a741556d452c Change mtv_read_packet so it does not break after seeking (displaying a shifted image).
reimar
parents: 3531
diff changeset
110 mtv->full_segment_size =
a741556d452c Change mtv_read_packet so it does not break after seeking (displaying a shifted image).
reimar
parents: 3531
diff changeset
111 audio_subsegments * (MTV_AUDIO_PADDING_SIZE + MTV_ASUBCHUNK_DATA_SIZE) +
a741556d452c Change mtv_read_packet so it does not break after seeking (displaying a shifted image).
reimar
parents: 3531
diff changeset
112 mtv->img_segment_size;
a741556d452c Change mtv_read_packet so it does not break after seeking (displaying a shifted image).
reimar
parents: 3531
diff changeset
113 mtv->video_fps = (mtv->audio_br / 4) / audio_subsegments;
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
114
4043
6eb27e4e1e83 Trivial, Cosmetics
reynaldo
parents: 3908
diff changeset
115 // FIXME Add sanity check here
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
116
4043
6eb27e4e1e83 Trivial, Cosmetics
reynaldo
parents: 3908
diff changeset
117 // all systems go! init decoders
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
118
4043
6eb27e4e1e83 Trivial, Cosmetics
reynaldo
parents: 3908
diff changeset
119 // video - raw rgb565
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
120
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
121 st = av_new_stream(s, VIDEO_SID);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
122 if(!st)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2023
diff changeset
123 return AVERROR(ENOMEM);
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
124
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
125 av_set_pts_info(st, 64, 1, mtv->video_fps);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
126 st->codec->codec_type = CODEC_TYPE_VIDEO;
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
127 st->codec->codec_id = CODEC_ID_RAWVIDEO;
1449
64a44155a525 now we set codec_tag, still have to figure out how to handle flipping
reynaldo
parents: 1380
diff changeset
128 st->codec->codec_tag = MKTAG('R', 'G', 'B', mtv->img_bpp);
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
129 st->codec->width = mtv->img_width;
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
130 st->codec->height = mtv->img_height;
3908
1d3d17de20ba Bump Major version, this commit is almost just renaming bits_per_sample to
michael
parents: 3532
diff changeset
131 st->codec->bits_per_coded_sample = mtv->img_bpp;
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
132 st->codec->sample_rate = mtv->video_fps;
5144
65f73f11261c Mark video from .mtv files correctly as upside-down.
reimar
parents: 5108
diff changeset
133 st->codec->extradata = av_strdup("BottomUp");
65f73f11261c Mark video from .mtv files correctly as upside-down.
reimar
parents: 5108
diff changeset
134 st->codec->extradata_size = 9;
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
135
4043
6eb27e4e1e83 Trivial, Cosmetics
reynaldo
parents: 3908
diff changeset
136 // audio - mp3
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
137
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
138 st = av_new_stream(s, AUDIO_SID);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
139 if(!st)
2273
7eb456c4ed8a Replace all occurrences of AVERROR_NOMEM with AVERROR(ENOMEM).
takis
parents: 2023
diff changeset
140 return AVERROR(ENOMEM);
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
141
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
142 av_set_pts_info(st, 64, 1, AUDIO_SAMPLING_RATE);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
143 st->codec->codec_type = CODEC_TYPE_AUDIO;
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
144 st->codec->codec_id = CODEC_ID_MP3;
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
145 st->codec->bit_rate = mtv->audio_br;
2023
a3e79d6e4e3c add an enum for need_parsing
aurel
parents: 2001
diff changeset
146 st->need_parsing = AVSTREAM_PARSE_FULL;
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
147
4043
6eb27e4e1e83 Trivial, Cosmetics
reynaldo
parents: 3908
diff changeset
148 // Jump over header
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
149
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
150 if(url_fseek(pb, MTV_HEADER_SIZE, SEEK_SET) != MTV_HEADER_SIZE)
2274
b21c2af60bc9 Replace all occurrences of AVERROR_IO with AVERROR(EIO).
takis
parents: 2273
diff changeset
151 return AVERROR(EIO);
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
152
3278
1de87c1b6a12 Remove unnecessary parentheses from return calls.
diego
parents: 2771
diff changeset
153 return 0;
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
154
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
155 }
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
156
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
157 static int mtv_read_packet(AVFormatContext *s, AVPacket *pkt)
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
158 {
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
159 MTVDemuxContext *mtv = s->priv_data;
2771
d52c718e83f9 Use dynamically allocated ByteIOContext in AVFormatContext
andoma
parents: 2274
diff changeset
160 ByteIOContext *pb = s->pb;
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
161 int ret;
5108
44a0fab134a9 Replace WORDS_BIGENDIAN with HAVE_BIGENDIAN
mru
parents: 4906
diff changeset
162 #if !HAVE_BIGENDIAN
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
163 int i;
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
164 #endif
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
165
3532
a741556d452c Change mtv_read_packet so it does not break after seeking (displaying a shifted image).
reimar
parents: 3531
diff changeset
166 if((url_ftell(pb) - s->data_offset + mtv->img_segment_size) % mtv->full_segment_size)
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
167 {
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
168 url_fskip(pb, MTV_AUDIO_PADDING_SIZE);
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
169
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
170 ret = av_get_packet(pb, pkt, MTV_ASUBCHUNK_DATA_SIZE);
5735
0f6f55a8e878 Plug memory leak for truncated files
vitor
parents: 5344
diff changeset
171 if(ret < 0)
0f6f55a8e878 Plug memory leak for truncated files
vitor
parents: 5344
diff changeset
172 return ret;
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
173
3531
296caaa22429 Fix pkt->pos to really point at start of packet for mtv audio packets.
reimar
parents: 3424
diff changeset
174 pkt->pos -= MTV_AUDIO_PADDING_SIZE;
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
175 pkt->stream_index = AUDIO_SID;
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
176
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
177 }else
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
178 {
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
179 ret = av_get_packet(pb, pkt, mtv->img_segment_size);
5735
0f6f55a8e878 Plug memory leak for truncated files
vitor
parents: 5344
diff changeset
180 if(ret < 0)
0f6f55a8e878 Plug memory leak for truncated files
vitor
parents: 5344
diff changeset
181 return ret;
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
182
5108
44a0fab134a9 Replace WORDS_BIGENDIAN with HAVE_BIGENDIAN
mru
parents: 4906
diff changeset
183 #if !HAVE_BIGENDIAN
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
184
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
185 /* pkt->data is GGGRRRR BBBBBGGG
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
186 * and we need RRRRRGGG GGGBBBBB
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
187 * for PIX_FMT_RGB565 so here we
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
188 * just swap bytes as they come
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
189 */
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
190
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
191 for(i=0;i<mtv->img_segment_size/2;i++)
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
192 *((uint16_t *)pkt->data+i) = bswap_16(*((uint16_t *)pkt->data+i));
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
193 #endif
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
194 pkt->stream_index = VIDEO_SID;
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
195 }
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
196
3278
1de87c1b6a12 Remove unnecessary parentheses from return calls.
diego
parents: 2771
diff changeset
197 return ret;
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
198 }
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
199
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
200 AVInputFormat mtv_demuxer = {
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
201 "MTV",
3424
7a0230981402 Make long_names in lavf/lavdev optional depending on CONFIG_SMALL.
diego
parents: 3286
diff changeset
202 NULL_IF_CONFIG_SMALL("MTV format"),
1380
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
203 sizeof(MTVDemuxContext),
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
204 mtv_probe,
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
205 mtv_read_header,
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
206 mtv_read_packet,
bfcb9fa1f431 new mtv demuxer
reynaldo
parents:
diff changeset
207 };