Mercurial > libavcodec.hg
changeset 1754:bdf3927bf8c5 libavcodec
closed gop support & flags2 as all bits in flags are used
and a few minor things i forgot to commit ...
author | michael |
---|---|
date | Thu, 22 Jan 2004 19:48:28 +0000 |
parents | bbf583d24584 |
children | b9309550c38f |
files | avcodec.h h263dec.c h264.c mjpeg.c mpeg12.c mpegvideo.c mpegvideo.h rv10.c svq1.c svq3.c |
diffstat | 10 files changed, 32 insertions(+), 14 deletions(-) [+] |
line wrap: on
line diff
--- 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
--- 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;
--- 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;
--- 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;
--- 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();
--- 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; i<b_frames; i++){
--- a/mpegvideo.h Thu Jan 22 12:09:14 2004 +0000 +++ b/mpegvideo.h Thu Jan 22 19:48:28 2004 +0000 @@ -255,6 +255,7 @@ int fixed_qscale; ///< fixed qscale if non zero int encoding; ///< true if we are encoding (vs decoding) int flags; ///< AVCodecContext.flags (HQ, MV4, ...) + int flags2; ///< AVCodecContext.flags2 int max_b_frames; ///< max number of b-frames for encoding int luma_elim_threshold; int chroma_elim_threshold; @@ -469,7 +470,6 @@ void *opaque; ///< private data for the user /* bit rate control */ - int I_frame_bits; //FIXME used in mpeg12 ... int64_t wanted_bits; int64_t total_bits; int frame_bits; ///< bits used for the current frame @@ -619,7 +619,6 @@ GetBitContext gb; /* Mpeg1 specific */ - int fake_picture_number; ///< picture number at the bitstream frame rate int gop_picture_number; ///< index of the first picture of a GOP based on fake_pic_num & mpeg1 specific int last_mv_dir; ///< last mv_dir, used for b frame encoding int broken_link; ///< no_output_of_prior_pics_flag
--- a/rv10.c Thu Jan 22 12:09:14 2004 +0000 +++ b/rv10.c Thu Jan 22 19:48:28 2004 +0000 @@ -474,8 +474,6 @@ av_log(s->avctx, 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;
--- 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,
--- 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) {