annotate cavsvideodec.c @ 6435:67433b0c29d5 libavformat

move h264 demuxer to its own file
author aurel
date Sun, 29 Aug 2010 21:28:51 +0000
parents 7ae181b3ca00
children 4775a49a6045
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 /*
6432
7ae181b3ca00 move cavsvideo demuxer to its own file
aurel
parents: 6431
diff changeset
2 * RAW Chinese AVS video demuxer
7ae181b3ca00 move cavsvideo demuxer to its own file
aurel
parents: 6431
diff changeset
3 * Copyright (c) 2009 Stefan Gehrer <stefan.gehrer@gmx.de>
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"
2545
213268d7594e move unrelated functions declarations out of allformats.h
aurel
parents: 2368
diff changeset
23 #include "raw.h"
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
24
4548
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
25 #define CAVS_SEQ_START_CODE 0x000001b0
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
26 #define CAVS_PIC_I_START_CODE 0x000001b3
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
27 #define CAVS_UNDEF_START_CODE 0x000001b4
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
28 #define CAVS_PIC_PB_START_CODE 0x000001b6
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
29 #define CAVS_VIDEO_EDIT_CODE 0x000001b7
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
30 #define CAVS_PROFILE_JIZHUN 0x20
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
31
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
32 static int cavsvideo_probe(AVProbeData *p)
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
33 {
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
34 uint32_t code= -1;
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
35 int pic=0, seq=0, slice_pos = 0;
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
36 int i;
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
37
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
38 for(i=0; i<p->buf_size; i++){
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
39 code = (code<<8) + p->buf[i];
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
40 if ((code & 0xffffff00) == 0x100) {
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
41 if(code < CAVS_SEQ_START_CODE) {
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
42 /* slices have to be consecutive */
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
43 if(code < slice_pos)
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
44 return 0;
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
45 slice_pos = code;
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
46 } else {
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
47 slice_pos = 0;
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
48 }
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
49 if (code == CAVS_SEQ_START_CODE) {
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
50 seq++;
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
51 /* check for the only currently supported profile */
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
52 if(p->buf[i+1] != CAVS_PROFILE_JIZHUN)
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
53 return 0;
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
54 } else if ((code == CAVS_PIC_I_START_CODE) ||
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
55 (code == CAVS_PIC_PB_START_CODE)) {
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
56 pic++;
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
57 } else if ((code == CAVS_UNDEF_START_CODE) ||
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
58 (code > CAVS_VIDEO_EDIT_CODE)) {
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
59 return 0;
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
60 }
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
61 }
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
62 }
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
63 if(seq && seq*9<=pic*10)
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
64 return AVPROBE_SCORE_MAX/2;
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
65 return 0;
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
66 }
0
05318cf2e886 renamed libav to libavformat
bellard
parents:
diff changeset
67
4548
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
68 AVInputFormat cavsvideo_demuxer = {
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
69 "cavsvideo",
4563
90e0047f90b6 consistent naming of Chinese AVS raw demuxer
stefang
parents: 4548
diff changeset
70 NULL_IF_CONFIG_SMALL("raw Chinese AVS video"),
4548
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
71 0,
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
72 cavsvideo_probe,
6430
d3a51b32b769 move ingenient demuxer to its own file
aurel
parents: 6429
diff changeset
73 ff_raw_video_read_header,
4610
41542d2edcf4 Separate the raw FLAC demuxer from raw.c and put in a new file,
jbr
parents: 4577
diff changeset
74 ff_raw_read_partial_packet,
4548
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
75 .flags= AVFMT_GENERIC_INDEX,
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
76 .value = CODEC_ID_CAVS,
2c9ebc4029ae add raw demuxer for Chinese AVS elementary streams
stefang
parents: 4510
diff changeset
77 };