# HG changeset patch # User michael # Date 1074800908 0 # Node ID bdf3927bf8c5ae534dda7dd50504ca95f24e33c7 # Parent bbf583d245848e9f2fd1f88593a89c780efa9357 closed gop support & flags2 as all bits in flags are used and a few minor things i forgot to commit ... diff -r bbf583d24584 -r bdf3927bf8c5 avcodec.h --- a/avcodec.h Thu Jan 22 12:09:14 2004 +0000 +++ b/avcodec.h Thu Jan 22 19:48:28 2004 +0000 @@ -270,6 +270,7 @@ #define CODEC_FLAG_H263P_SLICE_STRUCT 0x10000000 #define CODEC_FLAG_INTERLACED_ME 0x20000000 ///< interlaced motion estimation #define CODEC_FLAG_SVCD_SCAN_OFFSET 0x40000000 ///< will reserve space for SVCD scan offset user data +#define CODEC_FLAG_CLOSED_GOP 0x80000000 /* Unsupported options : * Syntax Arithmetic coding (SAC) * Reference Picture Selection diff -r bbf583d24584 -r bdf3927bf8c5 h263dec.c --- a/h263dec.c Thu Jan 22 12:09:14 2004 +0000 +++ b/h263dec.c Thu Jan 22 19:48:28 2004 +0000 @@ -393,6 +393,7 @@ printf("bytes=%x %x %x %x\n", buf[0], buf[1], buf[2], buf[3]); #endif s->flags= avctx->flags; + s->flags2= avctx->flags2; *data_size = 0; diff -r bbf583d24584 -r bdf3927bf8c5 h264.c --- a/h264.c Thu Jan 22 12:09:14 2004 +0000 +++ b/h264.c Thu Jan 22 19:48:28 2004 +0000 @@ -4131,6 +4131,7 @@ int buf_index; s->flags= avctx->flags; + s->flags2= avctx->flags2; *data_size = 0; diff -r bbf583d24584 -r bdf3927bf8c5 mjpeg.c --- a/mjpeg.c Thu Jan 22 12:09:14 2004 +0000 +++ b/mjpeg.c Thu Jan 22 19:48:28 2004 +0000 @@ -855,7 +855,6 @@ /* ugly way to get the idct & scantable FIXME */ memset(&s2, 0, sizeof(MpegEncContext)); - s2.flags= avctx->flags; s2.avctx= avctx; // s2->out_format = FMT_MJPEG; s2.width = 8; diff -r bbf583d24584 -r bdf3927bf8c5 mpeg12.c --- a/mpeg12.c Thu Jan 22 12:09:14 2004 +0000 +++ b/mpeg12.c Thu Jan 22 19:48:28 2004 +0000 @@ -330,7 +330,7 @@ put_bits(&s->pb, 1, 1); put_bits(&s->pb, 6, (uint32_t)((time_code / fps) % 60)); put_bits(&s->pb, 6, (uint32_t)((time_code % fps))); - put_bits(&s->pb, 1, 0); /* closed gop */ + put_bits(&s->pb, 1, !!(s->flags & CODEC_FLAG_CLOSED_GOP)); put_bits(&s->pb, 1, 0); /* broken link */ } } @@ -1706,6 +1706,7 @@ s->mpeg_enc_ctx.avctx= avctx; s->mpeg_enc_ctx.flags= avctx->flags; + s->mpeg_enc_ctx.flags2= avctx->flags2; common_init(&s->mpeg_enc_ctx); init_vlcs(); diff -r bbf583d24584 -r bdf3927bf8c5 mpegvideo.c --- a/mpegvideo.c Thu Jan 22 12:09:14 2004 +0000 +++ b/mpegvideo.c Thu Jan 22 19:48:28 2004 +0000 @@ -408,6 +408,7 @@ DCT_common_init(s); s->flags= s->avctx->flags; + s->flags2= s->avctx->flags2; s->mb_width = (s->width + 15) / 16; s->mb_height = (s->height + 15) / 16; @@ -700,6 +701,7 @@ s->gop_size = avctx->gop_size; s->avctx = avctx; s->flags= avctx->flags; + s->flags2= avctx->flags2; s->max_b_frames= avctx->max_b_frames; s->codec_id= avctx->codec->id; s->luma_elim_threshold = avctx->luma_elim_threshold; @@ -789,6 +791,11 @@ return -1; } + if(s->avctx->scenechange_threshold < 1000000000 && (s->flags & CODEC_FLAG_CLOSED_GOP)){ + av_log(avctx, AV_LOG_ERROR, "closed gop with scene change detection arent supported yet\n"); + return -1; + } + if(s->codec_id==CODEC_ID_MJPEG){ s->intra_quant_bias= 1<<(QUANT_BIAS_SHIFT-1); //(a + x/2)/x s->inter_quant_bias= 0; @@ -1809,12 +1816,19 @@ //static int b_count=0; //b_count+= b_frames; //av_log(s->avctx, AV_LOG_DEBUG, "b_frames: %d\n", b_count); - + if(s->picture_in_gop_number + b_frames >= s->gop_size){ + if(s->flags & CODEC_FLAG_CLOSED_GOP) + b_frames=0; + s->input_picture[b_frames]->pict_type= I_TYPE; + } + + if( (s->flags & CODEC_FLAG_CLOSED_GOP) + && b_frames + && s->input_picture[b_frames]->pict_type== I_TYPE) + b_frames--; + s->reordered_input_picture[0]= s->input_picture[b_frames]; - if( s->picture_in_gop_number + b_frames >= s->gop_size - || s->reordered_input_picture[0]->pict_type== I_TYPE) - s->reordered_input_picture[0]->pict_type= I_TYPE; - else + if(s->reordered_input_picture[0]->pict_type != I_TYPE) s->reordered_input_picture[0]->pict_type= P_TYPE; s->reordered_input_picture[0]->coded_picture_number= s->coded_picture_number++; for(i=0; iavctx, AV_LOG_ERROR, "unknown header %X\n", avctx->sub_id); } //printf("ver:%X\n", avctx->sub_id); - s->flags= avctx->flags; - if (MPV_common_init(s) < 0) return -1; diff -r bbf583d24584 -r bdf3927bf8c5 svq1.c --- a/svq1.c Thu Jan 22 12:09:14 2004 +0000 +++ b/svq1.c Thu Jan 22 19:48:28 2004 +0000 @@ -789,7 +789,6 @@ s->codec_id= avctx->codec->id; avctx->pix_fmt = PIX_FMT_YUV410P; avctx->has_b_frames= 1; // not true, but DP frames and these behave like unidirectional b frames - s->flags= avctx->flags; if (MPV_common_init(s) < 0) return -1; init_vlc(&svq1_block_type, 2, 4, diff -r bbf583d24584 -r bdf3927bf8c5 svq3.c --- a/svq3.c Thu Jan 22 12:09:14 2004 +0000 +++ b/svq3.c Thu Jan 22 19:48:28 2004 +0000 @@ -697,8 +697,10 @@ h->next_slice_index = s->gb.index + 8*show_bits (&s->gb, 8*length) + 8*length; - if (h->next_slice_index > s->gb.size_in_bits) + if (h->next_slice_index > s->gb.size_in_bits){ + av_log(h->s.avctx, AV_LOG_ERROR, "slice after bitstream end\n"); return -1; + } s->gb.size_in_bits = h->next_slice_index - 8*(length - 1); s->gb.index += 8; @@ -709,8 +711,10 @@ } } - if ((i = svq3_get_ue_golomb (&s->gb)) == INVALID_VLC || i >= 3) + if ((i = svq3_get_ue_golomb (&s->gb)) == INVALID_VLC || i >= 3){ + av_log(h->s.avctx, AV_LOG_ERROR, "illegal slice type %d \n", i); return -1; + } h->slice_type = golomb_to_pict_type[i]; @@ -766,6 +770,7 @@ *data_size = 0; s->flags = avctx->flags; + s->flags2 = avctx->flags2; s->unrestricted_mv = 1; if (!s->context_initialized) {