From 8c3b27ce279f1f0904af3c220d92acfa1f20a70e Mon Sep 17 00:00:00 2001 From: Anton Khirnov Date: Thu, 16 Jan 2014 15:40:37 +0100 Subject: Change libavcodec CODEC_ID_* to AV_CODEC_ID_* CODEC_ID_* have been replaced with AV_CODEC_ID_* in new libavcodec versions. Update the code to use those new identifiers. Added a compatibility code to ffmpeg_compat.h --- source/blender/blenkernel/intern/writeffmpeg.c | 74 +++++++++++++------------- source/blender/imbuf/intern/indexer.c | 2 +- source/blender/makesrna/intern/CMakeLists.txt | 3 ++ source/blender/makesrna/intern/SConscript | 2 +- source/blender/makesrna/intern/rna_scene.c | 43 +++++++-------- 5 files changed, 64 insertions(+), 60 deletions(-) (limited to 'source') diff --git a/source/blender/blenkernel/intern/writeffmpeg.c b/source/blender/blenkernel/intern/writeffmpeg.c index d975e60146f..38f80e7cee6 100644 --- a/source/blender/blenkernel/intern/writeffmpeg.c +++ b/source/blender/blenkernel/intern/writeffmpeg.c @@ -70,8 +70,8 @@ #include "ffmpeg_compat.h" static int ffmpeg_type = 0; -static int ffmpeg_codec = CODEC_ID_MPEG4; -static int ffmpeg_audio_codec = CODEC_ID_NONE; +static int ffmpeg_codec = AV_CODEC_ID_MPEG4; +static int ffmpeg_audio_codec = AV_CODEC_ID_NONE; static int ffmpeg_video_bitrate = 1150; static int ffmpeg_audio_bitrate = 128; static int ffmpeg_gop_size = 12; @@ -119,7 +119,7 @@ static void delete_picture(AVFrame *f) static int request_float_audio_buffer(int codec_id) { /* If any of these codecs, we prefer the float sample format (if supported) */ - return codec_id == CODEC_ID_AAC || codec_id == CODEC_ID_AC3 || codec_id == CODEC_ID_VORBIS; + return codec_id == AV_CODEC_ID_AAC || codec_id == AV_CODEC_ID_AC3 || codec_id == AV_CODEC_ID_VORBIS; } #ifdef WITH_AUDASPACE @@ -474,7 +474,7 @@ static int ffmpeg_proprty_valid(AVCodecContext *c, const char *prop_name, IDProp if (strcmp(prop_name, "video") == 0) { if (strcmp(curr->name, "bf") == 0) { /* flash codec doesn't support b frames */ - valid &= c->codec_id != CODEC_ID_FLV1; + valid &= c->codec_id != AV_CODEC_ID_FLV1; } } @@ -580,29 +580,29 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex c->codec_tag = (('D' << 24) + ('I' << 16) + ('V' << 8) + 'X'); } - if (codec_id == CODEC_ID_H264) { + if (codec_id == AV_CODEC_ID_H264) { /* correct wrong default ffmpeg param which crash x264 */ c->qmin = 10; c->qmax = 51; } /* Keep lossless encodes in the RGB domain. */ - if (codec_id == CODEC_ID_HUFFYUV) { + if (codec_id == AV_CODEC_ID_HUFFYUV) { /* HUFFYUV was PIX_FMT_YUV422P before */ c->pix_fmt = PIX_FMT_RGB32; } - if (codec_id == CODEC_ID_FFV1) { + if (codec_id == AV_CODEC_ID_FFV1) { c->pix_fmt = PIX_FMT_RGB32; } - if (codec_id == CODEC_ID_QTRLE) { + if (codec_id == AV_CODEC_ID_QTRLE) { if (rd->im_format.planes == R_IMF_PLANES_RGBA) { c->pix_fmt = PIX_FMT_ARGB; } } - if (codec_id == CODEC_ID_PNG) { + if (codec_id == AV_CODEC_ID_PNG) { if (rd->im_format.planes == R_IMF_PLANES_RGBA) { c->pix_fmt = PIX_FMT_ARGB; } @@ -638,7 +638,7 @@ static AVStream *alloc_video_stream(RenderData *rd, int codec_id, AVFormatContex return NULL; } - if (codec_id == CODEC_ID_QTRLE) { + if (codec_id == AV_CODEC_ID_QTRLE) { /* normally it should be enough to have buffer with actual image size, * but some codecs like QTRLE might store extra information in this buffer, * so it should be a way larger */ @@ -828,7 +828,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report of->oformat = fmt; of->packet_size = rd->ffcodecdata.mux_packet_size; - if (ffmpeg_audio_codec != CODEC_ID_NONE) { + if (ffmpeg_audio_codec != AV_CODEC_ID_NONE) { ffmpeg_dict_set_int(&opts, "muxrate", rd->ffcodecdata.mux_rate); } else { @@ -850,32 +850,32 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report fmt->video_codec = ffmpeg_codec; break; case FFMPEG_OGG: - fmt->video_codec = CODEC_ID_THEORA; + fmt->video_codec = AV_CODEC_ID_THEORA; break; case FFMPEG_DV: - fmt->video_codec = CODEC_ID_DVVIDEO; + fmt->video_codec = AV_CODEC_ID_DVVIDEO; break; case FFMPEG_MPEG1: - fmt->video_codec = CODEC_ID_MPEG1VIDEO; + fmt->video_codec = AV_CODEC_ID_MPEG1VIDEO; break; case FFMPEG_MPEG2: - fmt->video_codec = CODEC_ID_MPEG2VIDEO; + fmt->video_codec = AV_CODEC_ID_MPEG2VIDEO; break; case FFMPEG_H264: - fmt->video_codec = CODEC_ID_H264; + fmt->video_codec = AV_CODEC_ID_H264; break; case FFMPEG_XVID: - fmt->video_codec = CODEC_ID_MPEG4; + fmt->video_codec = AV_CODEC_ID_MPEG4; break; case FFMPEG_FLV: - fmt->video_codec = CODEC_ID_FLV1; + fmt->video_codec = AV_CODEC_ID_FLV1; break; case FFMPEG_MPEG4: default: - fmt->video_codec = CODEC_ID_MPEG4; + fmt->video_codec = AV_CODEC_ID_MPEG4; break; } - if (fmt->video_codec == CODEC_ID_DVVIDEO) { + if (fmt->video_codec == AV_CODEC_ID_DVVIDEO) { if (rectx != 720) { BKE_report(reports, RPT_ERROR, "Render width has to be 720 pixels for DV!"); return 0; @@ -891,15 +891,15 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report } if (ffmpeg_type == FFMPEG_DV) { - fmt->audio_codec = CODEC_ID_PCM_S16LE; - if (ffmpeg_audio_codec != CODEC_ID_NONE && rd->ffcodecdata.audio_mixrate != 48000 && rd->ffcodecdata.audio_channels != 2) { + fmt->audio_codec = AV_CODEC_ID_PCM_S16LE; + if (ffmpeg_audio_codec != AV_CODEC_ID_NONE && rd->ffcodecdata.audio_mixrate != 48000 && rd->ffcodecdata.audio_channels != 2) { BKE_report(reports, RPT_ERROR, "FFMPEG only supports 48khz / stereo audio for DV!"); av_dict_free(&opts); return 0; } } - if (fmt->video_codec != CODEC_ID_NONE) { + if (fmt->video_codec != AV_CODEC_ID_NONE) { video_stream = alloc_video_stream(rd, fmt->video_codec, of, rectx, recty, error, sizeof(error)); PRINT("alloc video stream %p\n", video_stream); if (!video_stream) { @@ -913,7 +913,7 @@ static int start_ffmpeg_impl(struct RenderData *rd, int rectx, int recty, Report } } - if (ffmpeg_audio_codec != CODEC_ID_NONE) { + if (ffmpeg_audio_codec != AV_CODEC_ID_NONE) { audio_stream = alloc_audio_stream(rd, fmt->audio_codec, of, error, sizeof(error)); if (!audio_stream) { if (error[0]) @@ -1418,7 +1418,7 @@ static void ffmpeg_set_expert_options(RenderData *rd) if (rd->ffcodecdata.properties) IDP_FreeProperty(rd->ffcodecdata.properties); - if (codec_id == CODEC_ID_H264) { + if (codec_id == AV_CODEC_ID_H264) { /* * All options here are for x264, but must be set via ffmpeg. * The names are therefore different - Search for "x264 to FFmpeg option mapping" @@ -1461,7 +1461,7 @@ static void ffmpeg_set_expert_options(RenderData *rd) if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT) BKE_ffmpeg_property_add_string(rd, "video", "cqp:0"); } - else if (codec_id == CODEC_ID_DNXHD) { + else if (codec_id == AV_CODEC_ID_DNXHD) { if (rd->ffcodecdata.flags & FFMPEG_LOSSLESS_OUTPUT) BKE_ffmpeg_property_add_string(rd, "video", "mbd:rd"); } @@ -1525,7 +1525,7 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset) case FFMPEG_PRESET_H264: rd->ffcodecdata.type = FFMPEG_AVI; - rd->ffcodecdata.codec = CODEC_ID_H264; + rd->ffcodecdata.codec = AV_CODEC_ID_H264; rd->ffcodecdata.video_bitrate = 6000; rd->ffcodecdata.gop_size = isntsc ? 18 : 15; rd->ffcodecdata.rc_max_rate = 9000; @@ -1540,11 +1540,11 @@ void BKE_ffmpeg_preset_set(RenderData *rd, int preset) case FFMPEG_PRESET_XVID: if (preset == FFMPEG_PRESET_XVID) { rd->ffcodecdata.type = FFMPEG_AVI; - rd->ffcodecdata.codec = CODEC_ID_MPEG4; + rd->ffcodecdata.codec = AV_CODEC_ID_MPEG4; } else if (preset == FFMPEG_PRESET_THEORA) { rd->ffcodecdata.type = FFMPEG_OGG; // XXX broken - rd->ffcodecdata.codec = CODEC_ID_THEORA; + rd->ffcodecdata.codec = AV_CODEC_ID_THEORA; } rd->ffcodecdata.video_bitrate = 6000; @@ -1571,7 +1571,7 @@ void BKE_ffmpeg_image_type_verify(RenderData *rd, ImageFormatData *imf) rd->ffcodecdata.audio_codec <= 0 || rd->ffcodecdata.video_bitrate <= 1) { - rd->ffcodecdata.codec = CODEC_ID_MPEG2VIDEO; + rd->ffcodecdata.codec = AV_CODEC_ID_MPEG2VIDEO; BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_DVD); } @@ -1582,26 +1582,26 @@ void BKE_ffmpeg_image_type_verify(RenderData *rd, ImageFormatData *imf) audio = 1; } else if (imf->imtype == R_IMF_IMTYPE_H264) { - if (rd->ffcodecdata.codec != CODEC_ID_H264) { + if (rd->ffcodecdata.codec != AV_CODEC_ID_H264) { BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_H264); audio = 1; } } else if (imf->imtype == R_IMF_IMTYPE_XVID) { - if (rd->ffcodecdata.codec != CODEC_ID_MPEG4) { + if (rd->ffcodecdata.codec != AV_CODEC_ID_MPEG4) { BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_XVID); audio = 1; } } else if (imf->imtype == R_IMF_IMTYPE_THEORA) { - if (rd->ffcodecdata.codec != CODEC_ID_THEORA) { + if (rd->ffcodecdata.codec != AV_CODEC_ID_THEORA) { BKE_ffmpeg_preset_set(rd, FFMPEG_PRESET_THEORA); audio = 1; } } if (audio && rd->ffcodecdata.audio_codec < 0) { - rd->ffcodecdata.audio_codec = CODEC_ID_NONE; + rd->ffcodecdata.audio_codec = AV_CODEC_ID_NONE; rd->ffcodecdata.audio_bitrate = 128; } } @@ -1615,14 +1615,14 @@ int BKE_ffmpeg_alpha_channel_is_supported(RenderData *rd) { int codec = rd->ffcodecdata.codec; - if (codec == CODEC_ID_QTRLE) + if (codec == AV_CODEC_ID_QTRLE) return TRUE; - if (codec == CODEC_ID_PNG) + if (codec == AV_CODEC_ID_PNG) return TRUE; #ifdef FFMPEG_FFV1_ALPHA_SUPPORTED - if (codec == CODEC_ID_FFV1) + if (codec == AV_CODEC_ID_FFV1) return TRUE; #endif diff --git a/source/blender/imbuf/intern/indexer.c b/source/blender/imbuf/intern/indexer.c index 49a40c461ac..74f39d544cc 100644 --- a/source/blender/imbuf/intern/indexer.c +++ b/source/blender/imbuf/intern/indexer.c @@ -504,7 +504,7 @@ static struct proxy_output_ctx *alloc_proxy_output_ffmpeg( rv->c = rv->st->codec; rv->c->codec_type = AVMEDIA_TYPE_VIDEO; - rv->c->codec_id = CODEC_ID_MJPEG; + rv->c->codec_id = AV_CODEC_ID_MJPEG; rv->c->width = width; rv->c->height = height; diff --git a/source/blender/makesrna/intern/CMakeLists.txt b/source/blender/makesrna/intern/CMakeLists.txt index 26904cac17f..240927efb73 100644 --- a/source/blender/makesrna/intern/CMakeLists.txt +++ b/source/blender/makesrna/intern/CMakeLists.txt @@ -211,6 +211,9 @@ if(WITH_CODEC_QUICKTIME) endif() if(WITH_CODEC_FFMPEG) + list(APPEND INC + ../../../../intern/ffmpeg + ) list(APPEND INC_SYS ${FFMPEG_INCLUDE_DIRS} ) diff --git a/source/blender/makesrna/intern/SConscript b/source/blender/makesrna/intern/SConscript index fe6950e62dd..b2229181303 100644 --- a/source/blender/makesrna/intern/SConscript +++ b/source/blender/makesrna/intern/SConscript @@ -108,7 +108,7 @@ if env['WITH_BF_FRAMESERVER']: if env['WITH_BF_FFMPEG']: defs.append('WITH_FFMPEG') - incs += ' ' + env['BF_FFMPEG_INC'] + incs += ' ' + env['BF_FFMPEG_INC'] + ' #/intern/ffmpeg' if env['WITH_BF_QUICKTIME']: defs.append('WITH_QUICKTIME') diff --git a/source/blender/makesrna/intern/rna_scene.c b/source/blender/makesrna/intern/rna_scene.c index b378c09a325..aa28afc1417 100644 --- a/source/blender/makesrna/intern/rna_scene.c +++ b/source/blender/makesrna/intern/rna_scene.c @@ -64,6 +64,7 @@ #include "BKE_writeffmpeg.h" #include #include +#include "ffmpeg_compat.h" #endif #include "ED_render.h" @@ -3756,31 +3757,31 @@ static void rna_def_scene_ffmpeg_settings(BlenderRNA *brna) }; static EnumPropertyItem ffmpeg_codec_items[] = { - {CODEC_ID_NONE, "NONE", 0, "None", ""}, - {CODEC_ID_MPEG1VIDEO, "MPEG1", 0, "MPEG-1", ""}, - {CODEC_ID_MPEG2VIDEO, "MPEG2", 0, "MPEG-2", ""}, - {CODEC_ID_MPEG4, "MPEG4", 0, "MPEG-4(divx)", ""}, - {CODEC_ID_HUFFYUV, "HUFFYUV", 0, "HuffYUV", ""}, - {CODEC_ID_DVVIDEO, "DV", 0, "DV", ""}, - {CODEC_ID_H264, "H264", 0, "H.264", ""}, - {CODEC_ID_THEORA, "THEORA", 0, "Theora", ""}, - {CODEC_ID_FLV1, "FLASH", 0, "Flash Video", ""}, - {CODEC_ID_FFV1, "FFV1", 0, "FFmpeg video codec #1", ""}, - {CODEC_ID_QTRLE, "QTRLE", 0, "QT rle / QT Animation", ""}, - {CODEC_ID_DNXHD, "DNXHD", 0, "DNxHD", ""}, - {CODEC_ID_PNG, "PNG", 0, "PNG", ""}, + {AV_CODEC_ID_NONE, "NONE", 0, "None", ""}, + {AV_CODEC_ID_MPEG1VIDEO, "MPEG1", 0, "MPEG-1", ""}, + {AV_CODEC_ID_MPEG2VIDEO, "MPEG2", 0, "MPEG-2", ""}, + {AV_CODEC_ID_MPEG4, "MPEG4", 0, "MPEG-4(divx)", ""}, + {AV_CODEC_ID_HUFFYUV, "HUFFYUV", 0, "HuffYUV", ""}, + {AV_CODEC_ID_DVVIDEO, "DV", 0, "DV", ""}, + {AV_CODEC_ID_H264, "H264", 0, "H.264", ""}, + {AV_CODEC_ID_THEORA, "THEORA", 0, "Theora", ""}, + {AV_CODEC_ID_FLV1, "FLASH", 0, "Flash Video", ""}, + {AV_CODEC_ID_FFV1, "FFV1", 0, "FFmpeg video codec #1", ""}, + {AV_CODEC_ID_QTRLE, "QTRLE", 0, "QT rle / QT Animation", ""}, + {AV_CODEC_ID_DNXHD, "DNXHD", 0, "DNxHD", ""}, + {AV_CODEC_ID_PNG, "PNG", 0, "PNG", ""}, {0, NULL, 0, NULL, NULL} }; static EnumPropertyItem ffmpeg_audio_codec_items[] = { - {CODEC_ID_NONE, "NONE", 0, "None", ""}, - {CODEC_ID_MP2, "MP2", 0, "MP2", ""}, - {CODEC_ID_MP3, "MP3", 0, "MP3", ""}, - {CODEC_ID_AC3, "AC3", 0, "AC3", ""}, - {CODEC_ID_AAC, "AAC", 0, "AAC", ""}, - {CODEC_ID_VORBIS, "VORBIS", 0, "Vorbis", ""}, - {CODEC_ID_FLAC, "FLAC", 0, "FLAC", ""}, - {CODEC_ID_PCM_S16LE, "PCM", 0, "PCM", ""}, + {AV_CODEC_ID_NONE, "NONE", 0, "None", ""}, + {AV_CODEC_ID_MP2, "MP2", 0, "MP2", ""}, + {AV_CODEC_ID_MP3, "MP3", 0, "MP3", ""}, + {AV_CODEC_ID_AC3, "AC3", 0, "AC3", ""}, + {AV_CODEC_ID_AAC, "AAC", 0, "AAC", ""}, + {AV_CODEC_ID_VORBIS, "VORBIS", 0, "Vorbis", ""}, + {AV_CODEC_ID_FLAC, "FLAC", 0, "FLAC", ""}, + {AV_CODEC_ID_PCM_S16LE, "PCM", 0, "PCM", ""}, {0, NULL, 0, NULL, NULL} }; #endif -- cgit v1.2.3