Revision e3507058

View differences:

libavformat/Makefile
103 103
OBJS-$(CONFIG_IV8_DEMUXER)               += iv8.o
104 104
OBJS-$(CONFIG_IVF_DEMUXER)               += ivfdec.o riff.o
105 105
OBJS-$(CONFIG_LMLM4_DEMUXER)             += lmlm4.o
106
OBJS-$(CONFIG_M4V_DEMUXER)               += raw.o
106
OBJS-$(CONFIG_M4V_DEMUXER)               += m4vdec.o raw.o
107 107
OBJS-$(CONFIG_M4V_MUXER)                 += raw.o
108 108
OBJS-$(CONFIG_MATROSKA_DEMUXER)          += matroskadec.o matroska.o \
109 109
                                            riff.o isom.o rmdec.o rm.o
libavformat/m4vdec.c
1
/*
2
 * RAW MPEG-4 video demuxer
3
 * Copyright (c) 2006  Thijs Vermeir <thijs.vermeir@barco.com>
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 "raw.h"
24

  
25
#define VISUAL_OBJECT_START_CODE       0x000001b5
26
#define VOP_START_CODE                 0x000001b6
27

  
28
static int mpeg4video_probe(AVProbeData *probe_packet)
29
{
30
    uint32_t temp_buffer= -1;
31
    int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
32
    int i;
33

  
34
    for(i=0; i<probe_packet->buf_size; i++){
35
        temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
36
        if ((temp_buffer & 0xffffff00) != 0x100)
37
            continue;
38

  
39
        if (temp_buffer == VOP_START_CODE)                         VOP++;
40
        else if (temp_buffer == VISUAL_OBJECT_START_CODE)          VISO++;
41
        else if (temp_buffer < 0x120)                              VO++;
42
        else if (temp_buffer < 0x130)                              VOL++;
43
        else if (   !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
44
                 && !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;
45
    }
46

  
47
    if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
48
        return AVPROBE_SCORE_MAX/2;
49
    return 0;
50
}
51

  
52
AVInputFormat m4v_demuxer = {
53
    "m4v",
54
    NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
55
    0,
56
    mpeg4video_probe, /** probing for MPEG-4 data */
57
    ff_raw_video_read_header,
58
    ff_raw_read_partial_packet,
59
    .flags= AVFMT_GENERIC_INDEX,
60
    .extensions = "m4v",
61
    .value = CODEC_ID_MPEG4,
62
};
libavformat/raw.c
241 241
}
242 242
#endif
243 243

  
244
#if CONFIG_M4V_DEMUXER
245
#define VISUAL_OBJECT_START_CODE       0x000001b5
246
#define VOP_START_CODE                 0x000001b6
247

  
248
static int mpeg4video_probe(AVProbeData *probe_packet)
249
{
250
    uint32_t temp_buffer= -1;
251
    int VO=0, VOL=0, VOP = 0, VISO = 0, res=0;
252
    int i;
253

  
254
    for(i=0; i<probe_packet->buf_size; i++){
255
        temp_buffer = (temp_buffer<<8) + probe_packet->buf[i];
256
        if ((temp_buffer & 0xffffff00) != 0x100)
257
            continue;
258

  
259
        if (temp_buffer == VOP_START_CODE)                         VOP++;
260
        else if (temp_buffer == VISUAL_OBJECT_START_CODE)          VISO++;
261
        else if (temp_buffer < 0x120)                              VO++;
262
        else if (temp_buffer < 0x130)                              VOL++;
263
        else if (   !(0x1AF < temp_buffer && temp_buffer < 0x1B7)
264
                 && !(0x1B9 < temp_buffer && temp_buffer < 0x1C4)) res++;
265
    }
266

  
267
    if ( VOP >= VISO && VOP >= VOL && VO >= VOL && VOL > 0 && res==0)
268
        return AVPROBE_SCORE_MAX/2;
269
    return 0;
270
}
271
#endif
272

  
273 244
#if CONFIG_H264_DEMUXER
274 245
static int h264_probe(AVProbeData *p)
275 246
{
......
735 706
};
736 707
#endif
737 708

  
738
#if CONFIG_M4V_DEMUXER
739
AVInputFormat m4v_demuxer = {
740
    "m4v",
741
    NULL_IF_CONFIG_SMALL("raw MPEG-4 video format"),
742
    0,
743
    mpeg4video_probe, /** probing for MPEG-4 data */
744
    ff_raw_video_read_header,
745
    ff_raw_read_partial_packet,
746
    .flags= AVFMT_GENERIC_INDEX,
747
    .extensions = "m4v",
748
    .value = CODEC_ID_MPEG4,
749
};
750
#endif
751

  
752 709
#if CONFIG_M4V_MUXER
753 710
AVOutputFormat m4v_muxer = {
754 711
    "m4v",

Also available in: Unified diff