Revision f3356e9c

View differences:

ffmpeg.c
136 136
static int video_inter_quant_bias= FF_DEFAULT_QUANT_BIAS;
137 137
static int me_method = ME_EPZS;
138 138
static int video_disable = 0;
139
static int video_discard = 0;
139 140
static int video_codec_id = CODEC_ID_NONE;
140 141
static int video_codec_tag = 0;
141 142
static int same_quality = 0;
......
2902 2903
            audio_channels = enc->channels;
2903 2904
            audio_sample_rate = enc->sample_rate;
2904 2905
            if(audio_disable)
2905
                ic->streams[i]->discard= 1;
2906
                ic->streams[i]->discard= AVDISCARD_ALL;
2906 2907
            break;
2907 2908
        case CODEC_TYPE_VIDEO:
2908 2909
            frame_height = enc->height;
......
2937 2938

  
2938 2939
            enc->rate_emu = rate_emu;
2939 2940
            if(video_disable)
2940
                ic->streams[i]->discard= 1;
2941
                ic->streams[i]->discard= AVDISCARD_ALL;
2942
            else if(video_discard)
2943
                ic->streams[i]->discard= video_discard;
2941 2944
            break;
2942 2945
        case CODEC_TYPE_DATA:
2943 2946
            break;
......
3947 3950
    { "g", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_gop_size}, "set the group of picture size", "gop_size" },
3948 3951
    { "intra", OPT_BOOL | OPT_EXPERT | OPT_VIDEO, {(void*)&intra_only}, "use only intra frames"},
3949 3952
    { "vn", OPT_BOOL | OPT_VIDEO, {(void*)&video_disable}, "disable video" },
3953
    { "vdt", OPT_INT | HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)&video_discard}, "discard threshold" },
3950 3954
    { "qscale", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qscale}, "use fixed video quantiser scale (VBR)", "q" },
3951 3955
    { "qmin", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qmin}, "min video quantiser scale (VBR)", "q" },
3952 3956
    { "qmax", HAS_ARG | OPT_EXPERT | OPT_VIDEO, {(void*)opt_qmax}, "max video quantiser scale (VBR)", "q" },
libavformat/asf.c
545 545
	    asf->packet_size_left -= rsize;
546 546
	    //printf("___objsize____  %d   %d    rs:%d\n", asf->packet_obj_size, asf->packet_frag_offset, rsize);
547 547

  
548
	    if (asf->stream_index < 0 || s->streams[asf->stream_index]->discard) {
548
	    if (asf->stream_index < 0
549
                || s->streams[asf->stream_index]->discard >= AVDISCARD_ALL
550
                || (!asf->packet_key_frame && s->streams[asf->stream_index]->discard >= AVDISCARD_NONKEY)
551
                ) {
549 552
                asf->packet_time_start = 0;
550 553
		/* unhandled packet (should not happen) */
551 554
		url_fskip(pb, asf->packet_frag_size);
libavformat/avformat.h
5 5
extern "C" {
6 6
#endif
7 7

  
8
#define LIBAVFORMAT_BUILD       4622
8
#define LIBAVFORMAT_BUILD       4623
9 9

  
10 10
#define LIBAVFORMAT_VERSION_INT FFMPEG_VERSION_INT
11 11
#define LIBAVFORMAT_VERSION     FFMPEG_VERSION
......
211 211
    int min_distance;         /* min distance between this and the previous keyframe, used to avoid unneeded searching */
212 212
} AVIndexEntry;
213 213

  
214
enum AVDiscard{
215
//we leave some space between them for extensions (drop some keyframes for intra only or drop just some bidir frames)
216
    AVDISCARD_NONE   =-16, ///< discard nothing
217
    AVDISCARD_DEFAULT=  0, ///< discard useless packets like 0 size packets in avi
218
    AVDISCARD_BIDIR  = 16, ///< discard all bidirectional frames
219
    AVDISCARD_NONKEY = 32, ///< discard all frames except keyframes
220
    AVDISCARD_ALL    = 48, ///< discard all
221
};
222

  
214 223
typedef struct AVStream {
215 224
    int index;    /* stream index in AVFormatContext */
216 225
    int id;       /* format specific stream id */
......
227 236
    int pts_wrap_bits; /* number of bits in pts (used for wrapping control) */
228 237
    /* ffmpeg.c private use */
229 238
    int stream_copy; /* if TRUE, just copy stream */
230
    int discard; ///< if 1, packets can be discarded at will and dont need to be demuxed
239
    enum AVDiscard discard; ///< selects which packets can be discarded at will and dont need to be demuxed
231 240
    //FIXME move stuff to a flags field?
232 241
    /* quality, as it has been removed from AVCodecContext and put in AVVideoFrame
233 242
     * MN:dunno if thats the right place, for it */
......
680 689
#endif
681 690

  
682 691
#endif /* AVFORMAT_H */
692

  
libavformat/avidec.c
532 532
          st = s->streams[n];
533 533
          ast = st->priv_data;
534 534
          
535
          if(st->discard){
535
          if(   (st->discard >= AVDISCARD_DEFAULT && size==0)
536
             /*|| (st->discard >= AVDISCARD_NONKEY && !(pkt->flags & PKT_FLAG_KEY))*/ //FIXME needs a little reordering
537
             || st->discard >= AVDISCARD_ALL){
538
                if(ast->sample_size) ast->frame_offset += pkt->size;
539
                else                 ast->frame_offset++;
536 540
                url_fskip(pb, size);
537 541
                goto resync;
538 542
          }
......
554 558
            ast->packet_size= size + 8;
555 559
            ast->remaining= size;
556 560
            goto resync;
557

  
558 561
          }
559 562
        }
560 563
        /* palette changed chunk */
libavformat/flvdec.c
105 105
        st->codec.frame_rate_base= 1;
106 106
        st->codec.frame_rate= 1000;
107 107
    }
108
    if(st->discard){
108
//    av_log(NULL, AV_LOG_DEBUG, "%d %X %d \n", is_audio, flags, st->discard);
109
    if(  (st->discard >= AVDISCARD_NONKEY && !((flags >> 4)==1 ||  is_audio))
110
       ||(st->discard >= AVDISCARD_BIDIR  &&  ((flags >> 4)==3 && !is_audio))
111
       || st->discard >= AVDISCARD_ALL
112
       ){
109 113
        url_fskip(&s->pb, size);
110 114
        continue;
111 115
    }
......
158 162
    pkt->pts = pts;
159 163
    pkt->stream_index = st->index;
160 164
    
161
    if (!is_audio && ((flags >> 4)==1))
165
    if (is_audio || ((flags >> 4)==1))
162 166
	pkt->flags |= PKT_FLAG_KEY;
163 167
    
164 168
    return ret;
libavformat/matroska.c
2420 2420
                    av_free(origdata);
2421 2421
                    break;
2422 2422
                }
2423
                if(matroska->ctx->streams[ matroska->tracks[track]->stream_index ]->discard){
2423
                if(matroska->ctx->streams[ matroska->tracks[track]->stream_index ]->discard >= AVDISCARD_ALL){
2424 2424
                    av_free(origdata);
2425 2425
                    break;                
2426 2426
                }
libavformat/mov.c
1855 1855
    }
1856 1856

  
1857 1857
//av_log(NULL, AV_LOG_DEBUG, "chunk: [%i] %lli -> %lli\n", st_id, mov->next_chunk_offset, offset);
1858
    if(!sc->is_ff_stream || s->streams[sc->ffindex]->discard) {
1858
    if(!sc->is_ff_stream || (s->streams[sc->ffindex]->discard >= AVDISCARD_ALL)) {
1859 1859
        url_fskip(&s->pb, (offset - mov->next_chunk_offset));
1860 1860
        mov->next_chunk_offset = offset;
1861 1861
	offset = 0x0FFFFFFFFFFFFFFFLL;
libavformat/mpeg.c
1541 1541
    if (codec_id != CODEC_ID_PCM_S16BE)
1542 1542
        st->need_parsing = 1;
1543 1543
 found:
1544
    if(st->discard)
1544
    if(st->discard >= AVDISCARD_ALL)
1545 1545
        goto skip;
1546 1546
    if (startcode >= 0xa0 && startcode <= 0xbf) {
1547 1547
        int b1, freq;
libavformat/nut.c
1222 1222
static int decode_frame(NUTContext *nut, AVPacket *pkt, int frame_code, int frame_type, int64_t frame_start){
1223 1223
    AVFormatContext *s= nut->avf;
1224 1224
    ByteIOContext *bc = &s->pb;
1225
    int size, stream_id, key_frame;
1226
    int64_t pts;
1225
    int size, stream_id, key_frame, discard;
1226
    int64_t pts, last_IP_pts;
1227 1227
    
1228 1228
    size= decode_frame_header(nut, &key_frame, &pts, &stream_id, frame_code, frame_type, frame_start);
1229 1229
    if(size < 0)
1230 1230
        return -1;
1231 1231

  
1232
    if(s->streams[ stream_id ]->discard){
1232
    discard= s->streams[ stream_id ]->discard;
1233
    last_IP_pts= s->streams[ stream_id ]->last_IP_pts;
1234
    if(  (discard >= AVDISCARD_NONKEY && !key_frame)
1235
       ||(discard >= AVDISCARD_BIDIR && last_IP_pts != AV_NOPTS_VALUE && last_IP_pts > pts)
1236
       || discard >= AVDISCARD_ALL){
1233 1237
        url_fskip(bc, size);
1234 1238
        return 1;
1235 1239
    }
libavformat/rm.c
854 854
            rm->remaining_len-= len;
855 855
        }
856 856

  
857
        if(st->discard){
857
        if(  (st->discard >= AVDISCARD_NONKEY && !(flags&2))
858
           || st->discard >= AVDISCARD_ALL){
858 859
            url_fskip(pb, len);
859 860
            goto resync;
860 861
        }
libavformat/utils.c
821 821
                compute_pkt_fields(s, st, NULL, pkt);
822 822
                s->cur_st = NULL;
823 823
                return 0;
824
            } else if (s->cur_len > 0 && !st->discard) {
824
            } else if (s->cur_len > 0 && st->discard < AVDISCARD_ALL) {
825 825
                len = av_parser_parse(st->parser, &st->codec, &pkt->data, &pkt->size, 
826 826
                                      s->cur_ptr, s->cur_len,
827 827
                                      s->cur_pkt.pts, s->cur_pkt.dts);

Also available in: Unified diff