[FFmpeg-devel] [PATCH] avcodec: wrapped avframe for audio
Nicolas George
george at nsup.org
Mon Aug 15 13:31:12 EEST 2016
L'octidi 28 thermidor, an CCXXIV, Paul B Mahol a écrit :
> Hi,
>
> patch attached.
> From c8f147cff360a4b187e2cf7ef1d848e162a156a8 Mon Sep 17 00:00:00 2001
> From: Paul B Mahol <onemda at gmail.com>
> Date: Sun, 14 Aug 2016 22:48:35 +0200
> Subject: [PATCH] avcodec: wrapped avframe for audio
>
> ---
> libavcodec/utils.c | 5 +++--
> libavformat/nullenc.c | 2 +-
> 2 files changed, 4 insertions(+), 3 deletions(-)
>
> diff --git a/libavcodec/utils.c b/libavcodec/utils.c
> index 783f62c..8280dd8 100644
> --- a/libavcodec/utils.c
> +++ b/libavcodec/utils.c
> @@ -1337,7 +1337,8 @@ int attribute_align_arg avcodec_open2(AVCodecContext *avctx, const AVCodec *code
> avctx->codec_id = codec->id;
> }
> if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type
> - && avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT)) {
> + && (avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT) &&
> + (avctx->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME))) {
Can you explain (in the commit message or as a comment maybe) why this
change is necessary for audio but not for video?
Also, the parentheses are unnecessary and make reading the condition harder.
I suggest, since the lines are changed anyway, to move the first && to the
end of the previous line:
+ if (avctx->codec_id != codec->id || (avctx->codec_type != codec->type &&
+ avctx->codec_type != AVMEDIA_TYPE_ATTACHMENT &&
+ avctx->codec_id != AV_CODEC_ID_WRAPPED_AVFRAME)) {
> av_log(avctx, AV_LOG_ERROR, "Codec type or id mismatches\n");
> ret = AVERROR(EINVAL);
> goto free_and_end;
> @@ -1824,7 +1825,7 @@ int attribute_align_arg avcodec_encode_audio2(AVCodecContext *avctx,
> }
>
> /* check for valid frame size */
> - if (frame) {
> + if (frame && avctx->codec->id != AV_CODEC_ID_WRAPPED_AVFRAME) {
> if (avctx->codec->capabilities & AV_CODEC_CAP_SMALL_LAST_FRAME) {
> if (frame->nb_samples > avctx->frame_size) {
> av_log(avctx, AV_LOG_ERROR, "more samples than frame size (avcodec_encode_audio2)\n");
> diff --git a/libavformat/nullenc.c b/libavformat/nullenc.c
> index fd293d7..3f08615 100644
> --- a/libavformat/nullenc.c
> +++ b/libavformat/nullenc.c
> @@ -29,7 +29,7 @@ static int null_write_packet(struct AVFormatContext *s, AVPacket *pkt)
> AVOutputFormat ff_null_muxer = {
> .name = "null",
> .long_name = NULL_IF_CONFIG_SMALL("raw null video"),
> - .audio_codec = AV_NE(AV_CODEC_ID_PCM_S16BE, AV_CODEC_ID_PCM_S16LE),
> + .audio_codec = AV_CODEC_ID_WRAPPED_AVFRAME,
> .video_codec = AV_CODEC_ID_WRAPPED_AVFRAME,
> .write_packet = null_write_packet,
> .flags = AVFMT_VARIABLE_FPS | AVFMT_NOFILE | AVFMT_NOTIMESTAMPS,
Regards,
--
Nicolas George
-------------- next part --------------
A non-text attachment was scrubbed...
Name: signature.asc
Type: application/pgp-signature
Size: 819 bytes
Desc: Digital signature
URL: <http://ffmpeg.org/pipermail/ffmpeg-devel/attachments/20160815/1c144091/attachment.sig>
More information about the ffmpeg-devel
mailing list