FFmpeg
avs3dec.c
Go to the documentation of this file.
1 /*
2  * RAW AVS3-P2/IEEE1857.10 video demuxer
3  * Copyright (c) 2020 Zhenyu Wang <wangzhenyu@pkusz.edu.cn>
4  * Bingjie Han <hanbj@pkusz.edu.cn>
5  * Huiwen Ren <hwrenx@gmail.com>
6  *
7  * This file is part of FFmpeg.
8  *
9  * FFmpeg is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 2.1 of the License, or (at your option) any later version.
13  *
14  * FFmpeg is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with FFmpeg; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  */
23 
24 #include "libavcodec/avs3.h"
25 #include "libavcodec/startcode.h"
26 #include "avformat.h"
27 #include "rawdec.h"
28 
29 static int avs3video_probe(const AVProbeData *p)
30 {
31  const uint8_t *ptr = p->buf, *end = p->buf + p->buf_size;
32  uint32_t code = -1;
33  uint8_t state = 0;
34  int pic = 0, seq = 0, slice_pos = 0;
35  int ret = 0;
36 
37  while (ptr < end) {
38  ptr = avpriv_find_start_code(ptr, end, &code);
39  state = code & 0xFF;
40  if ((code & 0xFFFFFF00) == 0x100) {
41  if (state < AVS3_SEQ_START_CODE) {
42  if (code < slice_pos)
43  return 0;
44  slice_pos = code;
45  } else {
46  slice_pos = 0;
47  }
48  if (state == AVS3_SEQ_START_CODE) {
49  seq++;
51  return 0;
52  } else if (AVS3_ISPIC(state)) {
53  pic++;
54  } else if ((state == AVS3_UNDEF_START_CODE) ||
56  return 0;
57  }
58  }
59  }
60 
61  if (seq && pic && av_match_ext(p->filename, "avs3")) {
63  }
64 
65  return ret;
66 }
67 
68 FF_DEF_RAWVIDEO_DEMUXER(avs3, "raw AVS3-P2/IEEE1857.10", avs3video_probe, "avs3", AV_CODEC_ID_AVS3)
AVProbeData::buf_size
int buf_size
Size of buf except extra allocated bytes.
Definition: avformat.h:456
AVS3_PROFILE_BASELINE_MAIN
#define AVS3_PROFILE_BASELINE_MAIN
Definition: avs3.h:36
AVPROBE_SCORE_MAX
#define AVPROBE_SCORE_MAX
maximum score
Definition: avformat.h:465
AVS3_UNDEF_START_CODE
#define AVS3_UNDEF_START_CODE
Definition: avs3.h:31
AVProbeData::buf
unsigned char * buf
Buffer must have AVPROBE_PADDING_SIZE of extra allocated bytes filled with zero.
Definition: avformat.h:455
AVProbeData::filename
const char * filename
Definition: avformat.h:454
av_match_ext
int av_match_ext(const char *filename, const char *extensions)
Return a positive value if the given filename has one of the given extensions, 0 otherwise.
Definition: format.c:40
AV_CODEC_ID_AVS3
@ AV_CODEC_ID_AVS3
Definition: codec_id.h:246
FF_DEF_RAWVIDEO_DEMUXER
#define FF_DEF_RAWVIDEO_DEMUXER(shortname, longname, probe, ext, id)
Definition: rawdec.h:66
rawdec.h
AVProbeData
This structure contains the data a format has to probe a file.
Definition: avformat.h:453
avpriv_find_start_code
const uint8_t * avpriv_find_start_code(const uint8_t *p, const uint8_t *end, uint32_t *state)
startcode.h
avs3video_probe
static int avs3video_probe(const AVProbeData *p)
Definition: avs3dec.c:29
state
static struct @327 state
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
ret
ret
Definition: filter_design.txt:187
AVS3_SEQ_START_CODE
#define AVS3_SEQ_START_CODE
Definition: avs3.h:27
avformat.h
avs3.h
AVS3_VIDEO_EDIT_CODE
#define AVS3_VIDEO_EDIT_CODE
Definition: avs3.h:34
AVS3_ISPIC
#define AVS3_ISPIC(x)
Definition: avs3.h:39
AVS3_PROFILE_BASELINE_MAIN10
#define AVS3_PROFILE_BASELINE_MAIN10
Definition: avs3.h:37