summaryrefslogtreecommitdiff
path: root/libavcodec
diff options
context:
space:
mode:
authorMichael Niedermayer <michaelni@gmx.at>2004-01-22 19:48:28 +0000
committerMichael Niedermayer <michaelni@gmx.at>2004-01-22 19:48:28 +0000
commit303e50e65b8b9dc66ef9929a5a638a16378da64c (patch)
tree1c4844019a66159a182fa2b059d008deda908c59 /libavcodec
parentd398a27e0b98f2d575d4e69ce4974768dff9f7d8 (diff)
closed gop support & flags2 as all bits in flags are used
and a few minor things i forgot to commit ... Originally committed as revision 2718 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'libavcodec')
-rw-r--r--libavcodec/avcodec.h1
-rw-r--r--libavcodec/h263dec.c1
-rw-r--r--libavcodec/h264.c1
-rw-r--r--libavcodec/mjpeg.c1
-rw-r--r--libavcodec/mpeg12.c3
-rw-r--r--libavcodec/mpegvideo.c24
-rw-r--r--libavcodec/mpegvideo.h3
-rw-r--r--libavcodec/rv10.c2
-rw-r--r--libavcodec/svq1.c1
-rw-r--r--libavcodec/svq3.c9
10 files changed, 32 insertions, 14 deletions
diff --git a/libavcodec/avcodec.h b/libavcodec/avcodec.h
index b58bfc266d..b6dee00eaf 100644
--- a/libavcodec/avcodec.h
+++ b/libavcodec/avcodec.h
@@ -270,6 +270,7 @@ static const __attribute__((unused)) int Motion_Est_QTab[] =
#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 --git a/libavcodec/h263dec.c b/libavcodec/h263dec.c
index 2ce41b4ba1..88db359fe9 100644
--- a/libavcodec/h263dec.c
+++ b/libavcodec/h263dec.c
@@ -393,6 +393,7 @@ uint64_t time= rdtsc();
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 --git a/libavcodec/h264.c b/libavcodec/h264.c
index 0de3827a53..43ed13e99f 100644
--- a/libavcodec/h264.c
+++ b/libavcodec/h264.c
@@ -4131,6 +4131,7 @@ static int decode_frame(AVCodecContext *avctx,
int buf_index;
s->flags= avctx->flags;
+ s->flags2= avctx->flags2;
*data_size = 0;
diff --git a/libavcodec/mjpeg.c b/libavcodec/mjpeg.c
index eeb177399c..1a948aa56f 100644
--- a/libavcodec/mjpeg.c
+++ b/libavcodec/mjpeg.c
@@ -855,7 +855,6 @@ static int mjpeg_decode_init(AVCodecContext *avctx)
/* 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 --git a/libavcodec/mpeg12.c b/libavcodec/mpeg12.c
index f76e714525..3edad5b802 100644
--- a/libavcodec/mpeg12.c
+++ b/libavcodec/mpeg12.c
@@ -330,7 +330,7 @@ static void mpeg1_encode_sequence_header(MpegEncContext *s)
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 @@ static int mpeg_decode_init(AVCodecContext *avctx)
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 --git a/libavcodec/mpegvideo.c b/libavcodec/mpegvideo.c
index 3f21349385..ec29e4d8bf 100644
--- a/libavcodec/mpegvideo.c
+++ b/libavcodec/mpegvideo.c
@@ -408,6 +408,7 @@ int MPV_common_init(MpegEncContext *s)
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 @@ int MPV_encode_init(AVCodecContext *avctx)
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 @@ int MPV_encode_init(AVCodecContext *avctx)
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 void select_input_picture(MpegEncContext *s){
//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++){
diff --git a/libavcodec/mpegvideo.h b/libavcodec/mpegvideo.h
index 5f742cb388..88e2f6d50b 100644
--- a/libavcodec/mpegvideo.h
+++ b/libavcodec/mpegvideo.h
@@ -255,6 +255,7 @@ typedef struct MpegEncContext {
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 @@ typedef struct MpegEncContext {
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 @@ typedef struct MpegEncContext {
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
diff --git a/libavcodec/rv10.c b/libavcodec/rv10.c
index 745d790b48..3b63464653 100644
--- a/libavcodec/rv10.c
+++ b/libavcodec/rv10.c
@@ -474,8 +474,6 @@ static int rv10_decode_init(AVCodecContext *avctx)
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;
diff --git a/libavcodec/svq1.c b/libavcodec/svq1.c
index bba2352dfc..6a15270b76 100644
--- a/libavcodec/svq1.c
+++ b/libavcodec/svq1.c
@@ -789,7 +789,6 @@ static int svq1_decode_init(AVCodecContext *avctx)
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 --git a/libavcodec/svq3.c b/libavcodec/svq3.c
index b160987a05..c8720c07aa 100644
--- a/libavcodec/svq3.c
+++ b/libavcodec/svq3.c
@@ -697,8 +697,10 @@ static int svq3_decode_slice_header (H264Context *h) {
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 @@ static int svq3_decode_slice_header (H264Context *h) {
}
}
- 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 @@ static int svq3_decode_frame (AVCodecContext *avctx,
*data_size = 0;
s->flags = avctx->flags;
+ s->flags2 = avctx->flags2;
s->unrestricted_mv = 1;
if (!s->context_initialized) {