mirror of
https://github.com/ossrs/srs.git
synced 2025-03-09 15:49:59 +00:00
For #1685: Cross build RTC with FFmpeg
This commit is contained in:
parent
1c75a270b3
commit
1e9de0e191
267 changed files with 12603 additions and 1451 deletions
64
trunk/3rdparty/ffmpeg-4-fit/libavcodec/utils.c
vendored
64
trunk/3rdparty/ffmpeg-4-fit/libavcodec/utils.c
vendored
|
@ -214,8 +214,6 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
|
|||
case AV_PIX_FMT_YUVA422P9BE:
|
||||
case AV_PIX_FMT_YUVA422P10LE:
|
||||
case AV_PIX_FMT_YUVA422P10BE:
|
||||
case AV_PIX_FMT_YUVA422P12LE:
|
||||
case AV_PIX_FMT_YUVA422P12BE:
|
||||
case AV_PIX_FMT_YUVA422P16LE:
|
||||
case AV_PIX_FMT_YUVA422P16BE:
|
||||
case AV_PIX_FMT_YUV440P10LE:
|
||||
|
@ -236,8 +234,6 @@ void avcodec_align_dimensions2(AVCodecContext *s, int *width, int *height,
|
|||
case AV_PIX_FMT_YUVA444P9BE:
|
||||
case AV_PIX_FMT_YUVA444P10LE:
|
||||
case AV_PIX_FMT_YUVA444P10BE:
|
||||
case AV_PIX_FMT_YUVA444P12LE:
|
||||
case AV_PIX_FMT_YUVA444P12BE:
|
||||
case AV_PIX_FMT_YUVA444P16LE:
|
||||
case AV_PIX_FMT_YUVA444P16BE:
|
||||
case AV_PIX_FMT_GBRP9LE:
|
||||
|
@ -412,7 +408,7 @@ int avcodec_fill_audio_frame(AVFrame *frame, int nb_channels,
|
|||
void ff_color_frame(AVFrame *frame, const int c[4])
|
||||
{
|
||||
const AVPixFmtDescriptor *desc = av_pix_fmt_desc_get(frame->format);
|
||||
int p, y, x;
|
||||
int p, y;
|
||||
|
||||
av_assert0(desc->flags & AV_PIX_FMT_FLAG_PLANAR);
|
||||
|
||||
|
@ -421,13 +417,19 @@ void ff_color_frame(AVFrame *frame, const int c[4])
|
|||
int is_chroma = p == 1 || p == 2;
|
||||
int bytes = is_chroma ? AV_CEIL_RSHIFT(frame->width, desc->log2_chroma_w) : frame->width;
|
||||
int height = is_chroma ? AV_CEIL_RSHIFT(frame->height, desc->log2_chroma_h) : frame->height;
|
||||
for (y = 0; y < height; y++) {
|
||||
if (desc->comp[0].depth >= 9) {
|
||||
for (x = 0; x<bytes; x++)
|
||||
((uint16_t*)dst)[x] = c[p];
|
||||
}else
|
||||
memset(dst, c[p], bytes);
|
||||
if (desc->comp[0].depth >= 9) {
|
||||
((uint16_t*)dst)[0] = c[p];
|
||||
av_memcpy_backptr(dst + 2, 2, bytes - 2);
|
||||
dst += frame->linesize[p];
|
||||
for (y = 1; y < height; y++) {
|
||||
memcpy(dst, frame->data[p], 2*bytes);
|
||||
dst += frame->linesize[p];
|
||||
}
|
||||
} else {
|
||||
for (y = 0; y < height; y++) {
|
||||
memset(dst, c[p], bytes);
|
||||
dst += frame->linesize[p];
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -678,8 +680,18 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
|
|||
if (av_codec_is_decoder(codec))
|
||||
av_freep(&avctx->subtitle_header);
|
||||
|
||||
if (avctx->channels > FF_SANE_NB_CHANNELS) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Too many channels: %d\n", avctx->channels);
|
||||
if (avctx->channels > FF_SANE_NB_CHANNELS || avctx->channels < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Too many or invalid channels: %d\n", avctx->channels);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto free_and_end;
|
||||
}
|
||||
if (avctx->sample_rate < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid sample rate: %d\n", avctx->sample_rate);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto free_and_end;
|
||||
}
|
||||
if (avctx->block_align < 0) {
|
||||
av_log(avctx, AV_LOG_ERROR, "Invalid block align: %d\n", avctx->block_align);
|
||||
ret = AVERROR(EINVAL);
|
||||
goto free_and_end;
|
||||
}
|
||||
|
@ -1029,6 +1041,9 @@ free_and_end:
|
|||
(avctx->codec->caps_internal & FF_CODEC_CAP_INIT_CLEANUP)))
|
||||
avctx->codec->close(avctx);
|
||||
|
||||
if (HAVE_THREADS && avctx->internal->thread_ctx)
|
||||
ff_thread_free(avctx);
|
||||
|
||||
if (codec->priv_class && codec->priv_data_size)
|
||||
av_opt_free(avctx->priv_data);
|
||||
av_opt_free(avctx);
|
||||
|
@ -1409,8 +1424,10 @@ const char *avcodec_profile_name(enum AVCodecID codec_id, int profile)
|
|||
|
||||
unsigned avcodec_version(void)
|
||||
{
|
||||
// av_assert0(AV_CODEC_ID_V410==164);
|
||||
av_assert0(AV_CODEC_ID_PCM_S8_PLANAR==65563);
|
||||
av_assert0(AV_CODEC_ID_ADPCM_G722==69660);
|
||||
// av_assert0(AV_CODEC_ID_BMV_AUDIO==86071);
|
||||
av_assert0(AV_CODEC_ID_SRT==94216);
|
||||
av_assert0(LIBAVCODEC_VERSION_MICRO >= 100);
|
||||
|
||||
|
@ -1605,6 +1622,8 @@ static int get_audio_frame_duration(enum AVCodecID id, int sr, int ch, int ba,
|
|||
return 256 * (frame_bytes / 64);
|
||||
if (id == AV_CODEC_ID_RA_144)
|
||||
return 160 * (frame_bytes / 20);
|
||||
if (id == AV_CODEC_ID_G723_1)
|
||||
return 240 * (frame_bytes / 24);
|
||||
|
||||
if (bps > 0) {
|
||||
/* calc from frame_bytes and bits_per_coded_sample */
|
||||
|
@ -2213,22 +2232,3 @@ int64_t ff_guess_coded_bitrate(AVCodecContext *avctx)
|
|||
|
||||
return bitrate;
|
||||
}
|
||||
|
||||
int ff_int_from_list_or_default(void *ctx, const char * val_name, int val,
|
||||
const int * array_valid_values, int default_value)
|
||||
{
|
||||
int i = 0, ref_val;
|
||||
|
||||
while (1) {
|
||||
ref_val = array_valid_values[i];
|
||||
if (ref_val == INT_MAX)
|
||||
break;
|
||||
if (val == ref_val)
|
||||
return val;
|
||||
i++;
|
||||
}
|
||||
/* val is not a valid value */
|
||||
av_log(ctx, AV_LOG_DEBUG,
|
||||
"%s %d are not supported. Set to default value : %d\n", val_name, val, default_value);
|
||||
return default_value;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue