You've already forked FFmpeg
mirror of
https://github.com/FFmpeg/FFmpeg.git
synced 2025-08-04 22:03:09 +02:00
avcodec/mpegvideo encs: Add put_bits_assume_flushed() to encode_header
This allows the compiler to remove the implicit "Do I need to output the PutBitContext buffer here?" checks. Signed-off-by: Andreas Rheinhardt <andreas.rheinhardt@outlook.com>
This commit is contained in:
@ -22,13 +22,14 @@
|
|||||||
#include "flvenc.h"
|
#include "flvenc.h"
|
||||||
#include "mpegvideo.h"
|
#include "mpegvideo.h"
|
||||||
#include "mpegvideoenc.h"
|
#include "mpegvideoenc.h"
|
||||||
|
#include "put_bits.h"
|
||||||
|
|
||||||
int ff_flv_encode_picture_header(MPVMainEncContext *const m)
|
int ff_flv_encode_picture_header(MPVMainEncContext *const m)
|
||||||
{
|
{
|
||||||
MPVEncContext *const s = &m->s;
|
MPVEncContext *const s = &m->s;
|
||||||
int format;
|
int format;
|
||||||
|
|
||||||
align_put_bits(&s->pb);
|
put_bits_assume_flushed(&s->pb);
|
||||||
|
|
||||||
put_bits(&s->pb, 17, 1);
|
put_bits(&s->pb, 17, 1);
|
||||||
/* 0: H.263 escape codes 1: 11-bit escape codes */
|
/* 0: H.263 escape codes 1: 11-bit escape codes */
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "h261.h"
|
#include "h261.h"
|
||||||
#include "h261enc.h"
|
#include "h261enc.h"
|
||||||
#include "mpegvideoenc.h"
|
#include "mpegvideoenc.h"
|
||||||
|
#include "put_bits.h"
|
||||||
|
|
||||||
#define H261_MAX_RUN 26
|
#define H261_MAX_RUN 26
|
||||||
#define H261_MAX_LEVEL 15
|
#define H261_MAX_LEVEL 15
|
||||||
@ -72,7 +73,7 @@ static int h261_encode_picture_header(MPVMainEncContext *const m)
|
|||||||
MPVEncContext *const s = &h->s.s;
|
MPVEncContext *const s = &h->s.s;
|
||||||
int temp_ref;
|
int temp_ref;
|
||||||
|
|
||||||
align_put_bits(&s->pb);
|
put_bits_assume_flushed(&s->pb);
|
||||||
|
|
||||||
put_bits(&s->pb, 20, 0x10); /* PSC */
|
put_bits(&s->pb, 20, 0x10); /* PSC */
|
||||||
|
|
||||||
|
@ -46,6 +46,7 @@
|
|||||||
#include "mathops.h"
|
#include "mathops.h"
|
||||||
#include "mpegutils.h"
|
#include "mpegutils.h"
|
||||||
#include "internal.h"
|
#include "internal.h"
|
||||||
|
#include "put_bits.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Table of number of bits a motion vector component needs.
|
* Table of number of bits a motion vector component needs.
|
||||||
@ -230,6 +231,8 @@ static int h263_encode_picture_header(MPVMainEncContext *const m)
|
|||||||
int best_error= INT_MAX;
|
int best_error= INT_MAX;
|
||||||
int custom_pcf;
|
int custom_pcf;
|
||||||
|
|
||||||
|
put_bits_assume_flushed(&s->pb);
|
||||||
|
|
||||||
if(s->c.h263_plus){
|
if(s->c.h263_plus){
|
||||||
for(i=0; i<2; i++){
|
for(i=0; i<2; i++){
|
||||||
int div, error;
|
int div, error;
|
||||||
@ -247,8 +250,6 @@ static int h263_encode_picture_header(MPVMainEncContext *const m)
|
|||||||
coded_frame_rate= 1800000;
|
coded_frame_rate= 1800000;
|
||||||
coded_frame_rate_base= (1000+best_clock_code)*best_divisor;
|
coded_frame_rate_base= (1000+best_clock_code)*best_divisor;
|
||||||
|
|
||||||
align_put_bits(&s->pb);
|
|
||||||
|
|
||||||
put_bits(&s->pb, 22, 0x20); /* PSC */
|
put_bits(&s->pb, 22, 0x20); /* PSC */
|
||||||
temp_ref= s->c.picture_number * (int64_t)coded_frame_rate * s->c.avctx->time_base.num / //FIXME use timestamp
|
temp_ref= s->c.picture_number * (int64_t)coded_frame_rate * s->c.avctx->time_base.num / //FIXME use timestamp
|
||||||
(coded_frame_rate_base * (int64_t)s->c.avctx->time_base.den);
|
(coded_frame_rate_base * (int64_t)s->c.avctx->time_base.den);
|
||||||
|
@ -49,6 +49,7 @@
|
|||||||
#include "mpegvideo.h"
|
#include "mpegvideo.h"
|
||||||
#include "mpegvideoenc.h"
|
#include "mpegvideoenc.h"
|
||||||
#include "profiles.h"
|
#include "profiles.h"
|
||||||
|
#include "put_bits.h"
|
||||||
#include "rl.h"
|
#include "rl.h"
|
||||||
|
|
||||||
#if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER
|
#if CONFIG_MPEG1VIDEO_ENCODER || CONFIG_MPEG2VIDEO_ENCODER
|
||||||
@ -155,6 +156,8 @@ static void mpeg1_encode_sequence_header(MPEG12EncContext *mpeg12)
|
|||||||
AVRational aspect_ratio = s->c.avctx->sample_aspect_ratio;
|
AVRational aspect_ratio = s->c.avctx->sample_aspect_ratio;
|
||||||
int aspect_ratio_info;
|
int aspect_ratio_info;
|
||||||
|
|
||||||
|
put_bits_assume_flushed(&s->pb);
|
||||||
|
|
||||||
if (!(s->c.cur_pic.ptr->f->flags & AV_FRAME_FLAG_KEY))
|
if (!(s->c.cur_pic.ptr->f->flags & AV_FRAME_FLAG_KEY))
|
||||||
return;
|
return;
|
||||||
|
|
||||||
@ -339,6 +342,8 @@ static int mpeg1_encode_picture_header(MPVMainEncContext *const m)
|
|||||||
MPVEncContext *const s = &m->s;
|
MPVEncContext *const s = &m->s;
|
||||||
const AVFrameSideData *side_data;
|
const AVFrameSideData *side_data;
|
||||||
|
|
||||||
|
put_bits_assume_flushed(&s->pb);
|
||||||
|
|
||||||
mpeg1_encode_sequence_header(mpeg12);
|
mpeg1_encode_sequence_header(mpeg12);
|
||||||
|
|
||||||
/* MPEG-1 picture header */
|
/* MPEG-1 picture header */
|
||||||
|
@ -35,6 +35,7 @@
|
|||||||
#include "mpeg4videoenc.h"
|
#include "mpeg4videoenc.h"
|
||||||
#include "mpegvideoenc.h"
|
#include "mpegvideoenc.h"
|
||||||
#include "profiles.h"
|
#include "profiles.h"
|
||||||
|
#include "put_bits.h"
|
||||||
#include "version.h"
|
#include "version.h"
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -1070,6 +1071,8 @@ static int mpeg4_encode_picture_header(MPVMainEncContext *const m)
|
|||||||
uint64_t time_incr;
|
uint64_t time_incr;
|
||||||
int64_t time_div, time_mod;
|
int64_t time_div, time_mod;
|
||||||
|
|
||||||
|
put_bits_assume_flushed(&s->pb);
|
||||||
|
|
||||||
if (s->c.pict_type == AV_PICTURE_TYPE_I) {
|
if (s->c.pict_type == AV_PICTURE_TYPE_I) {
|
||||||
if (!(s->c.avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) {
|
if (!(s->c.avctx->flags & AV_CODEC_FLAG_GLOBAL_HEADER)) {
|
||||||
if (s->c.avctx->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) // HACK, the reference sw is buggy
|
if (s->c.avctx->strict_std_compliance < FF_COMPLIANCE_VERY_STRICT) // HACK, the reference sw is buggy
|
||||||
|
@ -221,7 +221,8 @@ static int msmpeg4_encode_picture_header(MPVMainEncContext *const m)
|
|||||||
|
|
||||||
find_best_tables(ms);
|
find_best_tables(ms);
|
||||||
|
|
||||||
align_put_bits(&s->pb);
|
put_bits_assume_flushed(&s->pb);
|
||||||
|
|
||||||
put_bits(&s->pb, 2, s->c.pict_type - 1);
|
put_bits(&s->pb, 2, s->c.pict_type - 1);
|
||||||
|
|
||||||
put_bits(&s->pb, 5, s->c.qscale);
|
put_bits(&s->pb, 5, s->c.qscale);
|
||||||
|
@ -36,7 +36,7 @@ int ff_rv10_encode_picture_header(MPVMainEncContext *const m)
|
|||||||
MPVEncContext *const s = &m->s;
|
MPVEncContext *const s = &m->s;
|
||||||
int full_frame= 0;
|
int full_frame= 0;
|
||||||
|
|
||||||
align_put_bits(&s->pb);
|
put_bits_assume_flushed(&s->pb);
|
||||||
|
|
||||||
put_bits(&s->pb, 1, 1); /* marker */
|
put_bits(&s->pb, 1, 1); /* marker */
|
||||||
|
|
||||||
|
@ -38,6 +38,8 @@ int ff_rv20_encode_picture_header(MPVMainEncContext *const m)
|
|||||||
{
|
{
|
||||||
MPVEncContext *const s = &m->s;
|
MPVEncContext *const s = &m->s;
|
||||||
|
|
||||||
|
put_bits_assume_flushed(&s->pb);
|
||||||
|
|
||||||
put_bits(&s->pb, 2, s->c.pict_type); //I 0 vs. 1 ?
|
put_bits(&s->pb, 2, s->c.pict_type); //I 0 vs. 1 ?
|
||||||
put_bits(&s->pb, 1, 0); /* unknown bit */
|
put_bits(&s->pb, 1, 0); /* unknown bit */
|
||||||
put_bits(&s->pb, 5, s->c.qscale);
|
put_bits(&s->pb, 5, s->c.qscale);
|
||||||
|
@ -37,6 +37,7 @@
|
|||||||
#include "mpegvideo.h"
|
#include "mpegvideo.h"
|
||||||
#include "mpegvideodata.h"
|
#include "mpegvideodata.h"
|
||||||
#include "mpegvideoenc.h"
|
#include "mpegvideoenc.h"
|
||||||
|
#include "put_bits.h"
|
||||||
#include "rl.h"
|
#include "rl.h"
|
||||||
#include "speedhq.h"
|
#include "speedhq.h"
|
||||||
#include "speedhqenc.h"
|
#include "speedhqenc.h"
|
||||||
@ -101,6 +102,8 @@ static int speedhq_encode_picture_header(MPVMainEncContext *const m)
|
|||||||
SpeedHQEncContext *const ctx = (SpeedHQEncContext*)m;
|
SpeedHQEncContext *const ctx = (SpeedHQEncContext*)m;
|
||||||
MPVEncContext *const s = &m->s;
|
MPVEncContext *const s = &m->s;
|
||||||
|
|
||||||
|
put_bits_assume_flushed(&s->pb);
|
||||||
|
|
||||||
put_bits_le(&s->pb, 8, 100 - s->c.qscale * 2); /* FIXME why doubled */
|
put_bits_le(&s->pb, 8, 100 - s->c.qscale * 2); /* FIXME why doubled */
|
||||||
put_bits_le(&s->pb, 24, 4); /* no second field */
|
put_bits_le(&s->pb, 24, 4); /* no second field */
|
||||||
|
|
||||||
|
@ -28,6 +28,7 @@
|
|||||||
#include "msmpeg4enc.h"
|
#include "msmpeg4enc.h"
|
||||||
#include "msmpeg4data.h"
|
#include "msmpeg4data.h"
|
||||||
#include "msmpeg4_vc1_data.h"
|
#include "msmpeg4_vc1_data.h"
|
||||||
|
#include "put_bits.h"
|
||||||
#include "wmv2.h"
|
#include "wmv2.h"
|
||||||
|
|
||||||
#define WMV2_EXTRADATA_SIZE 4
|
#define WMV2_EXTRADATA_SIZE 4
|
||||||
@ -78,6 +79,8 @@ static int wmv2_encode_picture_header(MPVMainEncContext *const m)
|
|||||||
MSMPEG4EncContext *const ms = &w->msmpeg4;
|
MSMPEG4EncContext *const ms = &w->msmpeg4;
|
||||||
MPVEncContext *const s = &m->s;
|
MPVEncContext *const s = &m->s;
|
||||||
|
|
||||||
|
put_bits_assume_flushed(&s->pb);
|
||||||
|
|
||||||
put_bits(&s->pb, 1, s->c.pict_type - 1);
|
put_bits(&s->pb, 1, s->c.pict_type - 1);
|
||||||
if (s->c.pict_type == AV_PICTURE_TYPE_I)
|
if (s->c.pict_type == AV_PICTURE_TYPE_I)
|
||||||
put_bits(&s->pb, 7, 0);
|
put_bits(&s->pb, 7, 0);
|
||||||
|
Reference in New Issue
Block a user