FFmpeg
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Groups Pages
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(AVProbeData *p)
28 {
29  int seq = 0, entry = 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  continue;
43  }
44  level = (p->buf[i] & 0x38) >> 3;
45  if (level >= 5) {
46  seq = 0;
47  continue;
48  }
49  chromaformat = (p->buf[i] & 0x6) >> 1;
50  if (chromaformat != 1) {
51  seq = 0;
52  continue;
53  }
54  seq++;
55  i += 6;
56  break;
57  }
59  if (!seq)
60  continue;
61  entry++;
62  i += 2;
63  break;
64  case VC1_CODE_FRAME:
65  case VC1_CODE_FIELD:
66  case VC1_CODE_SLICE:
67  if (seq && entry)
68  frame++;
69  break;
70  }
71  }
72  }
73 
74  if (frame > 1)
75  return AVPROBE_SCORE_EXTENSION / 2 + 1;
76  if (frame == 1)
77  return AVPROBE_SCORE_EXTENSION / 4;
78  return 0;
79 }
80 
#define FF_DEF_RAWVIDEO_DEMUXER2(shortname, longname, probe, ext, id, flag)
Definition: rawdec.h:54
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:87
static AVFrame * frame
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:464
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:463
#define AVFMT_NOTIMESTAMPS
Format does not need / have any timestamps.
Definition: avformat.h:486
GLint GLenum type
Definition: opengl_enc.c:105
#define AVFMT_GENERIC_INDEX
Use generic index building code.
Definition: avformat.h:487
static int vc1_probe(AVProbeData *p)
Definition: vc1dec.c:27
#define AVPROBE_SCORE_EXTENSION
score for file extension
Definition: avformat.h:471
This structure contains the data a format has to probe a file.
Definition: avformat.h:461
mfxU16 profile
Definition: qsvenc.c:44
uint8_t level
Definition: svq3.c:207
Main libavformat public API header.