FFmpeg
vc1dec.c
Go to the documentation of this file.
1 /*
2  * VC-1 demuxer
3  * Copyright (c) 2015 Carl Eugen Hoyos
4  *
5  * This file is part of FFmpeg.
6  *
7  * FFmpeg is free software; you can redistribute it and/or
8  * modify it under the terms of the GNU Lesser General Public
9  * License as published by the Free Software Foundation; either
10  * version 2.1 of the License, or (at your option) any later version.
11  *
12  * FFmpeg is distributed in the hope that it will be useful,
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
18  * License along with FFmpeg; if not, write to the Free Software
19  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
20  */
21 
22 #include "avformat.h"
23 #include "rawdec.h"
24 #include "libavutil/intreadwrite.h"
25 #include "libavcodec/vc1_common.h"
26 
27 static int vc1_probe(const AVProbeData *p)
28 {
29  int seq = 0, entry = 0, invalid = 0, frame = 0, i;
30 
31  for (i = 0; i < p->buf_size + 5; i++) {
32  uint32_t code = AV_RB32(p->buf + i);
33  if ((code & 0xffffffe0) == 0x100) {
34  int type = code & 0x11f;
35  i += 4;
36  switch (type) {
37  case VC1_CODE_SEQHDR: {
38  int profile, level, chromaformat;
39  profile = (p->buf[i] & 0xc0) >> 6;
40  if (profile != PROFILE_ADVANCED) {
41  seq = 0;
42  invalid++;
43  continue;
44  }
45  level = (p->buf[i] & 0x38) >> 3;
46  if (level >= 5) {
47  seq = 0;
48  invalid++;
49  continue;
50  }
51  chromaformat = (p->buf[i] & 0x6) >> 1;
52  if (chromaformat != 1) {
53  seq = 0;
54  invalid++;
55  continue;
56  }
57  seq++;
58  i += 6;
59  break;
60  }
62  if (!seq) {
63  invalid++;
64  continue;
65  }
66  entry++;
67  i += 2;
68  break;
69  case VC1_CODE_FRAME:
70  case VC1_CODE_FIELD:
71  case VC1_CODE_SLICE:
72  if (seq && entry)
73  frame++;
74  break;
75  }
76  }
77  }
78 
79  if (frame > 1 && frame >> 1 > invalid)
80  return AVPROBE_SCORE_EXTENSION / 2 + 1;
81  if (frame >= 1)
82  return AVPROBE_SCORE_EXTENSION / 4;
83  return 0;
84 }
85 
entry
#define entry
Definition: aom_film_grain_template.c:66
level
uint8_t level
Definition: svq3.c:205
AVFMT_NOTIMESTAMPS
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition: avformat.h:479
AVProbeData::buf_size
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:454
AVFMT_GENERIC_INDEX
#define AVFMT_GENERIC_INDEX
Use generic index building code.
Definition: avformat.h:480
type
it s the only field you need to keep assuming you have a context There is some magic you don t need to care about around this just let it vf type
Definition: writing_filters.txt:86
VC1_CODE_SLICE
@ VC1_CODE_SLICE
Definition: vc1_common.h:36
intreadwrite.h
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:453
PROFILE_ADVANCED
@ PROFILE_ADVANCED
Definition: vc1_common.h:52
rawdec.h
VC1_CODE_SEQHDR
@ VC1_CODE_SEQHDR
Definition: vc1_common.h:40
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:451
VC1_CODE_FIELD
@ VC1_CODE_FIELD
Definition: vc1_common.h:37
VC1_CODE_ENTRYPOINT
@ VC1_CODE_ENTRYPOINT
Definition: vc1_common.h:39
VC1_CODE_FRAME
@ VC1_CODE_FRAME
Definition: vc1_common.h:38
AVPROBE_SCORE_EXTENSION
#define AVPROBE_SCORE_EXTENSION
score for file extension
Definition: avformat.h:461
vc1_probe
static int vc1_probe(const AVProbeData *p)
Definition: vc1dec.c:27
AV_RB32
uint64_t_TMPL AV_WL64 unsigned int_TMPL AV_WL32 unsigned int_TMPL AV_WL24 unsigned int_TMPL AV_WL16 uint64_t_TMPL AV_WB64 unsigned int_TMPL AV_RB32
Definition: bytestream.h:96
vc1_common.h
i
#define i(width, name, range_min, range_max)
Definition: cbs_h2645.c:256
code
and forward the test the status of outputs and forward it to the corresponding return FFERROR_NOT_READY If the filters stores internally one or a few frame for some it can consider them to be part of the FIFO and delay acknowledging a status change accordingly Example code
Definition: filter_design.txt:178
AV_CODEC_ID_VC1
@ AV_CODEC_ID_VC1
Definition: codec_id.h:122
profile
int profile
Definition: mxfenc.c:2228
frame
these buffered frames must be flushed immediately if a new input produces new the filter must not call request_frame to get more It must just process the frame or queue it The task of requesting more frames is left to the filter s request_frame method or the application If a filter has several the filter must be ready for frames arriving randomly on any input any filter with several inputs will most likely require some kind of queuing mechanism It is perfectly acceptable to have a limited queue and to drop frames when the inputs are too unbalanced request_frame For filters that do not use the this method is called when a frame is wanted on an output For a it should directly call filter_frame on the corresponding output For a if there are queued frames already one of these frames should be pushed If the filter should request a frame on one of its repeatedly until at least one frame has been pushed Return or at least make progress towards producing a frame
Definition: filter_design.txt:264
avformat.h
FF_DEF_RAWVIDEO_DEMUXER2
#define FF_DEF_RAWVIDEO_DEMUXER2(shortname, longname, probe, ext, id, flag)
Definition: rawdec.h:53