annotate rawvideodec.c @ 6449:3a28e6827095 libavformat

Solving memory leak and initialization problem with prev_pkt / pkt.
author bindhammer
date Tue, 31 Aug 2010 07:15:11 +0000
parents 4775a49a6045
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
885
da1d5db0ce5c COSMETICS: Remove all trailing whitespace.
diego
parents: 868
diff changeset
1 /*
6447
ef0ad6df55b2 move raw video demuxer to its own file
aurel
parents: 6446
diff changeset
2 * RAW video demuxer
4251
77e0c7511d41 cosmetics: Remove pointless period after copyright statement non-sentences.
diego
parents: 4206
diff changeset
3 * Copyright (c) 2001 Fabrice Bellard
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
4 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1245
diff changeset
5 * This file is part of FFmpeg.
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1245
diff changeset
6 *
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1245
diff changeset
7 * FFmpeg is free software; you can redistribute it and/or
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
8 * modify it under the terms of the GNU Lesser General Public
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
9 * License as published by the Free Software Foundation; either
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1245
diff changeset
10 * version 2.1 of the License, or (at your option) any later version.
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
11 *
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1245
diff changeset
12 * FFmpeg is distributed in the hope that it will be useful,
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
15 * Lesser General Public License for more details.
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
16 *
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
17 * You should have received a copy of the GNU Lesser General Public
1358
0899bfe4105c Change license headers to say 'FFmpeg' instead of 'this program/this library'
diego
parents: 1245
diff changeset
18 * License along with FFmpeg; if not, write to the Free Software
896
edbe5c3717f9 Update licensing information: The FSF changed postal address.
diego
parents: 887
diff changeset
19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
20 */
3286
6f61c3b36632 Use full path for #includes from another directory.
diego
parents: 3274
diff changeset
21
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
22 #include "avformat.h"
6448
4775a49a6045 split raw.c into rawdec.c and rawenc.c
aurel
parents: 6447
diff changeset
23 #include "rawdec.h"
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24
3546
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
25 static int rawvideo_read_packet(AVFormatContext *s, AVPacket *pkt)
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
26 {
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
27 int packet_size, ret, width, height;
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
28 AVStream *st = s->streams[0];
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
29
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
30 width = st->codec->width;
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
31 height = st->codec->height;
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
32
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
33 packet_size = avpicture_get_size(st->codec->pix_fmt, width, height);
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
34 if (packet_size < 0)
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
35 return -1;
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
36
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
37 ret= av_get_packet(s->pb, pkt, packet_size);
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
38 pkt->pts=
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
39 pkt->dts= pkt->pos / packet_size;
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
40
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
41 pkt->stream_index = 0;
5254
83cc2a571542 Return any error return values from av_get_packet, get_buffer etc. unchanged
reimar
parents: 5249
diff changeset
42 if (ret < 0)
83cc2a571542 Return any error return values from av_get_packet, get_buffer etc. unchanged
reimar
parents: 5249
diff changeset
43 return ret;
5248
938a1b27357a Simplify: remove pointless {} and else
reimar
parents: 5247
diff changeset
44 return 0;
3546
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
45 }
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
46
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
47 AVInputFormat rawvideo_demuxer = {
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
48 "rawvideo",
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
49 NULL_IF_CONFIG_SMALL("raw video format"),
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
50 0,
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
51 NULL,
6445
4aaed59641ff move pcm demuxers to their own file
aurel
parents: 6443
diff changeset
52 ff_raw_read_header,
3546
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
53 rawvideo_read_packet,
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
54 .flags= AVFMT_GENERIC_INDEX,
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
55 .extensions = "yuv,cif,qcif,rgb",
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
56 .value = CODEC_ID_RAWVIDEO,
45c3d2b2b2fb Alphabetically order AVInputFormat/AVOutputFormat declarations.
diego
parents: 3545
diff changeset
57 };