New upstream version 5.0.1

This commit is contained in:
nyanmisaka
2022-04-27 20:24:39 +08:00
parent 0dc42ed11e
commit b2af5b16fa
2502 changed files with 116308 additions and 53581 deletions
+7 -58
View File
@@ -24,6 +24,7 @@
#include "libavutil/opt.h"
#include "libavutil/pixdesc.h"
#include "avcodec.h"
#include "encode.h"
#include "internal.h"
#include "packet_internal.h"
#include "snow_dwt.h"
@@ -41,13 +42,6 @@ static av_cold int encode_init(AVCodecContext *avctx)
int plane_index, ret;
int i;
#if FF_API_PRIVATE_OPT
FF_DISABLE_DEPRECATION_WARNINGS
if (avctx->prediction_method)
s->pred = avctx->prediction_method;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if(s->pred == DWT_97
&& (avctx->flags & AV_CODEC_FLAG_QSCALE)
&& avctx->global_quality == 0){
@@ -85,7 +79,7 @@ FF_ENABLE_DEPRECATION_WARNINGS
s->m.mb_num = (avctx->width * avctx->height + 255) / 256; // For ratecontrol
s->m.me.temp =
s->m.me.scratchpad= av_mallocz_array((avctx->width+64), 2*16*2*sizeof(uint8_t));
s->m.me.scratchpad = av_calloc(avctx->width + 64, 2*16*2*sizeof(uint8_t));
s->m.me.map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->m.me.score_map = av_mallocz(ME_MAP_SIZE*sizeof(uint32_t));
s->m.sc.obmc_scratchpad= av_mallocz(MB_SIZE*MB_SIZE*12*sizeof(uint32_t));
@@ -126,17 +120,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
/* case AV_PIX_FMT_RGB32:
s->colorspace= 1;
break;*/
default:
av_log(avctx, AV_LOG_ERROR, "pixel format not supported\n");
return AVERROR_PATCHWELCOME;
}
ret = av_pix_fmt_get_chroma_sub_sample(avctx->pix_fmt, &s->chroma_h_shift,
&s->chroma_v_shift);
if (ret) {
av_log(avctx, AV_LOG_ERROR, "pixel format invalid or unknown\n");
if (ret)
return ret;
}
ff_set_cmp(&s->mecc, s->mecc.me_cmp, s->avctx->me_cmp);
ff_set_cmp(&s->mecc, s->mecc.me_sub_cmp, s->avctx->me_sub_cmp);
@@ -151,8 +140,8 @@ FF_ENABLE_DEPRECATION_WARNINGS
if(s->motion_est == FF_ME_ITER){
int size= s->b_width * s->b_height << 2*s->block_max_depth;
for(i=0; i<s->max_ref_frames; i++){
s->ref_mvs[i]= av_mallocz_array(size, sizeof(int16_t[2]));
s->ref_scores[i]= av_mallocz_array(size, sizeof(uint32_t));
s->ref_mvs[i] = av_calloc(size, sizeof(*s->ref_mvs[i]));
s->ref_scores[i] = av_calloc(size, sizeof(*s->ref_scores[i]));
if (!s->ref_mvs[i] || !s->ref_scores[i])
return AVERROR(ENOMEM);
}
@@ -1576,7 +1565,7 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
uint8_t rc_header_bak[sizeof(s->header_state)];
uint8_t rc_block_bak[sizeof(s->block_state)];
if ((ret = ff_alloc_packet2(avctx, pkt, s->b_width*s->b_height*MB_SIZE*MB_SIZE*3 + AV_INPUT_BUFFER_MIN_SIZE, 0)) < 0)
if ((ret = ff_alloc_packet(avctx, pkt, s->b_width*s->b_height*MB_SIZE*MB_SIZE*3 + AV_INPUT_BUFFER_MIN_SIZE)) < 0)
return ret;
ff_init_range_encoder(c, pkt->data, pkt->size);
@@ -1625,22 +1614,10 @@ static int encode_frame(AVCodecContext *avctx, AVPacket *pkt,
s->lambda = 0;
}//else keep previous frame's qlog until after motion estimation
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
av_frame_unref(avctx->coded_frame);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (s->current_picture->data[0]) {
int w = s->avctx->width;
int h = s->avctx->height;
#if FF_API_CODED_FRAME
ret = av_frame_make_writable(s->current_picture);
if (ret < 0)
return ret;
#endif
s->mpvencdsp.draw_edges(s->current_picture->data[0],
s->current_picture->linesize[0], w , h ,
EDGE_WIDTH , EDGE_WIDTH , EDGE_TOP | EDGE_BOTTOM);
@@ -1656,13 +1633,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
}
ff_snow_frame_start(s);
#if FF_API_CODED_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
ret = av_frame_ref(avctx->coded_frame, s->current_picture);
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if (ret < 0)
return ret;
s->m.current_picture_ptr= &s->m.current_picture;
s->m.current_picture.f = s->current_picture;
@@ -1759,13 +1729,6 @@ redo_frame:
}
predict_plane(s, s->spatial_idwt_buffer, plane_index, 0);
#if FF_API_PRIVATE_OPT
FF_DISABLE_DEPRECATION_WARNINGS
if(s->avctx->scenechange_threshold)
s->scenechange_threshold = s->avctx->scenechange_threshold;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
if( plane_index==0
&& pic->pict_type == AV_PICTURE_TYPE_P
&& !(avctx->flags&AV_CODEC_FLAG_PASS2)
@@ -1890,14 +1853,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
if(avctx->flags&AV_CODEC_FLAG_PASS1)
ff_write_pass1_stats(&s->m);
s->m.last_pict_type = s->m.pict_type;
#if FF_API_STAT_BITS
FF_DISABLE_DEPRECATION_WARNINGS
avctx->frame_bits = s->m.frame_bits;
avctx->mv_bits = s->m.mv_bits;
avctx->misc_bits = s->m.misc_bits;
avctx->p_tex_bits = s->m.p_tex_bits;
FF_ENABLE_DEPRECATION_WARNINGS
#endif
emms_c();
@@ -1906,12 +1861,6 @@ FF_ENABLE_DEPRECATION_WARNINGS
(s->avctx->flags&AV_CODEC_FLAG_PSNR) ? 4 : 0,
s->current_picture->pict_type);
#if FF_API_ERROR_FRAME
FF_DISABLE_DEPRECATION_WARNINGS
memcpy(s->current_picture->error, s->encoding_error, sizeof(s->encoding_error));
FF_ENABLE_DEPRECATION_WARNINGS
#endif
pkt->size = ff_rac_terminate(c, 0);
if (s->current_picture->key_frame)
pkt->flags |= AV_PKT_FLAG_KEY;
@@ -1963,7 +1912,7 @@ static const AVClass snowenc_class = {
.version = LIBAVUTIL_VERSION_INT,
};
AVCodec ff_snow_encoder = {
const AVCodec ff_snow_encoder = {
.name = "snow",
.long_name = NULL_IF_CONFIG_SMALL("Snow"),
.type = AVMEDIA_TYPE_VIDEO,