early-access version 1680

This commit is contained in:
pineappleEA
2021-05-13 11:45:27 +02:00
parent 1434d96e7d
commit 66ed389c6f
311 changed files with 6452 additions and 2597 deletions

View File

@@ -50,6 +50,7 @@
#include "thread.h"
#include "frame_thread_encoder.h"
#include "internal.h"
#include "put_bits.h"
#include "raw.h"
#include "bytestream.h"
#include "version.h"
@@ -93,7 +94,7 @@ void av_fast_padded_mallocz(void *ptr, unsigned int *size, size_t min_size)
int av_codec_is_encoder(const AVCodec *codec)
{
return codec && (codec->encode_sub || codec->encode2 ||codec->send_frame);
return codec && (codec->encode_sub || codec->encode2 || codec->receive_packet);
}
int av_codec_is_decoder(const AVCodec *codec)
@@ -585,13 +586,16 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
avci->to_free = av_frame_alloc();
avci->compat_decode_frame = av_frame_alloc();
avci->compat_encode_packet = av_packet_alloc();
avci->buffer_frame = av_frame_alloc();
avci->buffer_pkt = av_packet_alloc();
avci->es.in_frame = av_frame_alloc();
avci->ds.in_pkt = av_packet_alloc();
avci->last_pkt_props = av_packet_alloc();
if (!avci->to_free || !avci->compat_decode_frame ||
if (!avci->compat_decode_frame || !avci->compat_encode_packet ||
!avci->buffer_frame || !avci->buffer_pkt ||
!avci->ds.in_pkt || !avci->last_pkt_props) {
!avci->es.in_frame || !avci->ds.in_pkt ||
!avci->to_free || !avci->last_pkt_props) {
ret = AVERROR(ENOMEM);
goto free_and_end;
}
@@ -1041,10 +1045,12 @@ FF_ENABLE_DEPRECATION_WARNINGS
av_frame_free(&avci->to_free);
av_frame_free(&avci->compat_decode_frame);
av_frame_free(&avci->buffer_frame);
av_packet_free(&avci->compat_encode_packet);
av_packet_free(&avci->buffer_pkt);
av_packet_free(&avci->last_pkt_props);
av_packet_free(&avci->ds.in_pkt);
av_frame_free(&avci->es.in_frame);
av_bsf_free(&avci->bsf);
av_buffer_unref(&avci->pool);
@@ -1079,9 +1085,10 @@ void avcodec_flush_buffers(AVCodecContext *avctx)
avci->nb_draining_errors = 0;
av_frame_unref(avci->buffer_frame);
av_frame_unref(avci->compat_decode_frame);
av_packet_unref(avci->compat_encode_packet);
av_packet_unref(avci->buffer_pkt);
avci->buffer_pkt_valid = 0;
av_frame_unref(avci->es.in_frame);
av_packet_unref(avci->ds.in_pkt);
if (HAVE_THREADS && avctx->active_thread_type & FF_THREAD_FRAME)
@@ -1139,10 +1146,12 @@ av_cold int avcodec_close(AVCodecContext *avctx)
av_frame_free(&avctx->internal->to_free);
av_frame_free(&avctx->internal->compat_decode_frame);
av_frame_free(&avctx->internal->buffer_frame);
av_packet_free(&avctx->internal->compat_encode_packet);
av_packet_free(&avctx->internal->buffer_pkt);
av_packet_free(&avctx->internal->last_pkt_props);
av_packet_free(&avctx->internal->ds.in_pkt);
av_frame_free(&avctx->internal->es.in_frame);
av_buffer_unref(&avctx->internal->pool);
@@ -2236,6 +2245,68 @@ int ff_alloc_a53_sei(const AVFrame *frame, size_t prefix_len,
return 0;
}
static unsigned bcd2uint(uint8_t bcd)
{
unsigned low = bcd & 0xf;
unsigned high = bcd >> 4;
if (low > 9 || high > 9)
return 0;
return low + 10*high;
}
int ff_alloc_timecode_sei(const AVFrame *frame, size_t prefix_len,
void **data, size_t *sei_size)
{
AVFrameSideData *sd = NULL;
uint8_t *sei_data;
PutBitContext pb;
uint32_t *tc;
int m;
if (frame)
sd = av_frame_get_side_data(frame, AV_FRAME_DATA_S12M_TIMECODE);
if (!sd) {
*data = NULL;
return 0;
}
tc = (uint32_t*)sd->data;
m = tc[0] & 3;
*sei_size = sizeof(uint32_t) * 4;
*data = av_mallocz(*sei_size + prefix_len);
if (!*data)
return AVERROR(ENOMEM);
sei_data = (uint8_t*)*data + prefix_len;
init_put_bits(&pb, sei_data, *sei_size);
put_bits(&pb, 2, m); // num_clock_ts
for (int j = 1; j <= m; j++) {
uint32_t tcsmpte = tc[j];
unsigned hh = bcd2uint(tcsmpte & 0x3f); // 6-bit hours
unsigned mm = bcd2uint(tcsmpte>>8 & 0x7f); // 7-bit minutes
unsigned ss = bcd2uint(tcsmpte>>16 & 0x7f); // 7-bit seconds
unsigned ff = bcd2uint(tcsmpte>>24 & 0x3f); // 6-bit frames
unsigned drop = tcsmpte & 1<<30 && !0; // 1-bit drop if not arbitrary bit
put_bits(&pb, 1, 1); // clock_timestamp_flag
put_bits(&pb, 1, 1); // units_field_based_flag
put_bits(&pb, 5, 0); // counting_type
put_bits(&pb, 1, 1); // full_timestamp_flag
put_bits(&pb, 1, 0); // discontinuity_flag
put_bits(&pb, 1, drop);
put_bits(&pb, 9, ff);
put_bits(&pb, 6, ss);
put_bits(&pb, 6, mm);
put_bits(&pb, 5, hh);
put_bits(&pb, 5, 0);
}
flush_put_bits(&pb);
return 0;
}
int64_t ff_guess_coded_bitrate(AVCodecContext *avctx)
{
AVRational framerate = avctx->framerate;