mirror of
https://gitee.com/openharmony/third_party_ffmpeg
synced 2024-12-03 16:51:18 +00:00
workaround dc_scale bug in old ffmpeg msmpeg4v3 encoder (set workaround_bugs=1 for this)
Originally committed as revision 561 to svn://svn.ffmpeg.org/ffmpeg/trunk
This commit is contained in:
parent
ddad77fade
commit
92ba5ffbb5
@ -5,8 +5,8 @@
|
||||
|
||||
#define LIBAVCODEC_VERSION_INT 0x000406
|
||||
#define LIBAVCODEC_VERSION "0.4.6"
|
||||
#define LIBAVCODEC_BUILD 4609
|
||||
#define LIBAVCODEC_BUILD_STR "4609"
|
||||
#define LIBAVCODEC_BUILD 4610
|
||||
#define LIBAVCODEC_BUILD_STR "4610"
|
||||
|
||||
enum CodecID {
|
||||
CODEC_ID_NONE,
|
||||
@ -231,6 +231,8 @@ typedef struct AVCodecContext {
|
||||
enum CodecType codec_type; /* see CODEC_TYPE_xxx */
|
||||
enum CodecID codec_id; /* see CODEC_ID_xxx */
|
||||
unsigned int codec_tag; /* codec tag, only used if unknown codec */
|
||||
|
||||
int workaround_bugs; /* workaround bugs in encoders which cannot be detected automatically */
|
||||
/*
|
||||
Note: Below are located reserved fields for further usage
|
||||
It requires for ABI !!!
|
||||
@ -253,7 +255,7 @@ typedef struct AVCodecContext {
|
||||
ul_res6,ul_res7,ul_res8,ul_res9,ul_res10,ul_res11,ul_res12;
|
||||
unsigned int
|
||||
ui_res0,ui_res1,ui_res2,ui_res3,ui_res4,ui_res5,
|
||||
ui_res6,ui_res7,ui_res8,ui_res9,ui_res10,ui_res11,ui_res12;
|
||||
ui_res6,ui_res7,ui_res8,ui_res9,ui_res10,ui_res11;
|
||||
unsigned short int
|
||||
us_res0,us_res1,us_res2,us_res3,us_res4,us_res5,
|
||||
us_res6,us_res7,us_res8,us_res9,us_res10,us_res11,us_res12;
|
||||
|
@ -43,6 +43,7 @@ static int h263_decode_init(AVCodecContext *avctx)
|
||||
|
||||
s->width = avctx->width;
|
||||
s->height = avctx->height;
|
||||
s->workaround_bugs= avctx->workaround_bugs;
|
||||
|
||||
/* select sub codec */
|
||||
switch(avctx->codec->id) {
|
||||
@ -211,7 +212,11 @@ uint64_t time= rdtsc();
|
||||
//fprintf(stderr,"\nFrame: %d\tMB: %d",avctx->frame_number, (s->mb_y * s->mb_width) + s->mb_x);
|
||||
/* DCT & quantize */
|
||||
if (s->h263_pred && s->msmpeg4_version!=2) {
|
||||
h263_dc_scale(s);
|
||||
/* old ffmpeg encoded msmpeg4v3 workaround */
|
||||
if(s->workaround_bugs==1 && s->msmpeg4_version==3)
|
||||
ff_old_msmpeg4_dc_scale(s);
|
||||
else
|
||||
h263_dc_scale(s);
|
||||
} else {
|
||||
/* default quantization values */
|
||||
s->y_dc_scale = 8;
|
||||
@ -277,9 +282,9 @@ uint64_t time= rdtsc();
|
||||
s->has_b_frames=1;
|
||||
for(mb_y=0; mb_y<s->mb_height; mb_y++){
|
||||
int mb_x;
|
||||
int y= mb_y*16;
|
||||
int y= mb_y*16 + 8;
|
||||
for(mb_x=0; mb_x<s->mb_width; mb_x++){
|
||||
int x= mb_x*16;
|
||||
int x= mb_x*16 + 8;
|
||||
uint8_t *ptr= s->last_picture[0];
|
||||
int xy= 1 + mb_x*2 + (mb_y*2 + 1)*(s->mb_width*2 + 2);
|
||||
int mx= (s->motion_val[xy][0]>>1) + x;
|
||||
@ -299,6 +304,7 @@ uint64_t time= rdtsc();
|
||||
int y1= y + (my-y)*i/max;
|
||||
ptr[y1*s->linesize + x1]+=100;
|
||||
}
|
||||
ptr[y*s->linesize + x]+=100;
|
||||
s->mbskip_table[mb_x + mb_y*s->mb_width]=0;
|
||||
}
|
||||
}
|
||||
|
@ -99,6 +99,7 @@ typedef struct MpegEncContext {
|
||||
float b_quant_factor;/* qscale factor between ips and b frames */
|
||||
int rc_strategy;
|
||||
int b_frame_strategy;
|
||||
int workaround_bugs; /* workaround bugs in encoders which cannot be detected automatically */
|
||||
/* the following fields are managed internally by the encoder */
|
||||
|
||||
/* bit output */
|
||||
@ -491,6 +492,7 @@ int msmpeg4_decode_ext_header(MpegEncContext * s, int buf_size);
|
||||
int msmpeg4_decode_mb(MpegEncContext *s,
|
||||
DCTELEM block[6][64]);
|
||||
int msmpeg4_decode_init_vlc(MpegEncContext *s);
|
||||
void ff_old_msmpeg4_dc_scale(MpegEncContext *s);
|
||||
|
||||
/* mjpegenc.c */
|
||||
|
||||
|
@ -15,11 +15,14 @@
|
||||
* You should have received a copy of the GNU General Public License
|
||||
* along with this program; if not, write to the Free Software
|
||||
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
|
||||
*
|
||||
* msmpeg4v2 stuff by Michael Niedermayer <michaelni@gmx.at>
|
||||
*/
|
||||
#include "avcodec.h"
|
||||
#include "dsputil.h"
|
||||
#include "mpegvideo.h"
|
||||
|
||||
|
||||
/*
|
||||
* You can also call this codec : MPEG4 with a twist !
|
||||
*
|
||||
@ -407,26 +410,20 @@ void msmpeg4_encode_mb(MpegEncContext * s,
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
#if 0
|
||||
/* identical to mpeg4 for msmpeg4v3 but not msmpeg4v2 */
|
||||
void msmpeg4_dc_scale(MpegEncContext * s)
|
||||
/* old ffmpeg msmpeg4v3 mode */
|
||||
void ff_old_msmpeg4_dc_scale(MpegEncContext * s)
|
||||
{
|
||||
if (s->qscale < 5 || s->msmpeg4_version==2){
|
||||
if (s->qscale < 5){
|
||||
s->y_dc_scale = 8;
|
||||
s->c_dc_scale = 8;
|
||||
}else if (s->qscale < 9){
|
||||
s->y_dc_scale = 2 * s->qscale;
|
||||
s->c_dc_scale = (s->qscale + 13)>>1;
|
||||
}else if(s->qscale < 25){
|
||||
}else{
|
||||
s->y_dc_scale = s->qscale + 8;
|
||||
s->c_dc_scale = (s->qscale + 13)>>1;
|
||||
}else{
|
||||
s->y_dc_scale = 2 * s->qscale - 16;
|
||||
s->c_dc_scale = s->qscale - 6;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/* dir = 0: left, dir = 1: top prediction */
|
||||
static int msmpeg4_pred_dc(MpegEncContext * s, int n,
|
||||
|
Loading…
Reference in New Issue
Block a user