History

ffmpeg: remove ffmpeg_videotoolbox

This was almost completely redundant. The only functionality that's no longer available after this removal is the videotoolbox_pixfmt arg, which has been obsolete for several years.

rcombs committed 5 years ago

Commit 4b548181 parent 5593f5c5 files · +7 −249Browse files

Unified · Split

5 files
  1. fftools/Makefile +0 −4
  2. fftools/ffmpeg.c +3 −34
  3. fftools/ffmpeg.h +0 −10
  4. fftools/ffmpeg_opt.c +4 −24
  5. fftools/ffmpeg_videotoolbox.c +0 −177
fftools/Makefile+0−4
@@ -10,10 +10,6 @@ ALLAVPROGS = $(AVBASENAMES:%=%$(PROGSSUF)$(EXESUF)) · 9 unmodified lines
1010 ALLAVPROGS_G = $(AVBASENAMES:%=%$(PROGSSUF)_g$(EXESUF))
1111
1212 OBJS-ffmpeg += fftools/ffmpeg_opt.o fftools/ffmpeg_filter.o fftools/ffmpeg_hw.o
13−ifndef CONFIG_VIDEOTOOLBOX
14−OBJS-ffmpeg-$(CONFIG_VDA) += fftools/ffmpeg_videotoolbox.o
15−endif
16−OBJS-ffmpeg-$(CONFIG_VIDEOTOOLBOX) += fftools/ffmpeg_videotoolbox.o
1713
1814 define DOFFTOOL
1915 OBJS-$(1) += fftools/cmdutils.o fftools/$(1).o $(OBJS-$(1)-yes)
fftools/ffmpeg.c+3−34
@@ -2858,12 +2858,7 @@ static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat · 2857 unmodified lines
28582858 break;
28592859 }
28602860 }
2861− if (config) {
2862− if (config->device_type != ist->hwaccel_device_type) {
2863− // Different hwaccel offered, ignore.
2864− continue;
2865− }
2866−
2861+ if (config && config->device_type == ist->hwaccel_device_type) {
28672862 ret = hwaccel_decode_init(s);
28682863 if (ret < 0) {
28692864 if (ist->hwaccel_id == HWACCEL_GENERIC) {
@@ -2876,36 +2871,10 @@ static enum AVPixelFormat get_format(AVCodecContext *s, const enum AVPixelFormat · 6 unmodified lines
28762871 }
28772872 continue;
28782873 }
2879− } else {
2880− const HWAccel *hwaccel = NULL;
2881− int i;
2882− for (i = 0; hwaccels[i].name; i++) {
2883− if (hwaccels[i].pix_fmt == *p) {
2884− hwaccel = &hwaccels[i];
2885− break;
2886− }
2887− }
2888− if (!hwaccel) {
2889− // No hwaccel supporting this pixfmt.
2890− continue;
2891− }
2892− if (hwaccel->id != ist->hwaccel_id) {
2893− // Does not match requested hwaccel.
2894− continue;
2895− }
28962874
2897− ret = hwaccel->init(s);
2898− if (ret < 0) {
2899− av_log(NULL, AV_LOG_FATAL,
2900− "%s hwaccel requested for input stream #%d:%d, "
2901− "but cannot be initialized.\n", hwaccel->name,
2902− ist->file_index, ist->st->index);
2903− return AV_PIX_FMT_NONE;
2904− }
2875+ ist->hwaccel_pix_fmt = *p;
2876+ break;
29052877 }
2906−
2907− ist->hwaccel_pix_fmt = *p;
2908− break;
29092878 }
29102879
29112880 return *p;
fftools/ffmpeg.h+0−10
@@ -60,16 +60,8 @@ enum HWAccelID { · 59 unmodified lines
6060 HWACCEL_NONE = 0,
6161 HWACCEL_AUTO,
6262 HWACCEL_GENERIC,
63− HWACCEL_VIDEOTOOLBOX,
6463 };
6564
66−typedef struct HWAccel {
67− const char *name;
68− int (*init)(AVCodecContext *s);
69− enum HWAccelID id;
70− enum AVPixelFormat pix_fmt;
71−} HWAccel;
72−
7365 typedef struct HWDevice {
7466 const char *name;
7567 enum AVHWDeviceType type;
@@ -626,7 +618,6 @@ extern int stdin_interaction; · 550 unmodified lines
626618 extern int frame_bits_per_raw_sample;
627619 extern AVIOContext *progress_avio;
628620 extern float max_error_rate;
629−extern char *videotoolbox_pixfmt;
630621
631622 extern char *filter_nbthreads;
632623 extern int filter_complex_nbthreads;
@@ -636,7 +627,6 @@ extern int auto_conversion_filters; · 3 unmodified lines
636627 extern const AVIOInterruptCB int_cb;
637628
638629 extern const OptionDef options[];
639−extern const HWAccel hwaccels[];
640630 #if CONFIG_QSV
641631 extern char *qsv_device;
642632 #endif
fftools/ffmpeg_opt.c+4−24
@@ -134,12 +134,6 @@ static const char *const opt_name_enc_time_bases[] = {"enc_time_base" · 133 unmodified lines
134134 }\
135135 }
136136
137−const HWAccel hwaccels[] = {
138−#if CONFIG_VIDEOTOOLBOX
139− { "videotoolbox", videotoolbox_init, HWACCEL_VIDEOTOOLBOX, AV_PIX_FMT_VIDEOTOOLBOX },
140−#endif
141− { 0 },
142−};
143137 HWDevice *filter_hw_device;
144138
145139 char *vstats_filename;
@@ -931,21 +925,10 @@ static void add_input_streams(OptionsContext *o, AVFormatContext *ic) · 785 unmodified lines
931925 else if (!strcmp(hwaccel, "auto"))
932926 ist->hwaccel_id = HWACCEL_AUTO;
933927 else {
934− enum AVHWDeviceType type;
935− int i;
936− for (i = 0; hwaccels[i].name; i++) {
937− if (!strcmp(hwaccels[i].name, hwaccel)) {
938− ist->hwaccel_id = hwaccels[i].id;
939− break;
940− }
941− }
942−
943− if (!ist->hwaccel_id) {
944− type = av_hwdevice_find_type_by_name(hwaccel);
945− if (type != AV_HWDEVICE_TYPE_NONE) {
946− ist->hwaccel_id = HWACCEL_GENERIC;
947− ist->hwaccel_device_type = type;
948− }
928+ enum AVHWDeviceType type = av_hwdevice_find_type_by_name(hwaccel);
929+ if (type != AV_HWDEVICE_TYPE_NONE) {
930+ ist->hwaccel_id = HWACCEL_GENERIC;
931+ ist->hwaccel_device_type = type;
949932 }
950933
951934 if (!ist->hwaccel_id) {
@@ -3811,9 +3794,6 @@ const OptionDef options[] = { · 2859 unmodified lines
38113794 { "hwaccel_output_format", OPT_VIDEO | OPT_STRING | HAS_ARG | OPT_EXPERT |
38123795 OPT_SPEC | OPT_INPUT, { .off = OFFSET(hwaccel_output_formats) },
38133796 "select output format used with HW accelerated decoding", "format" },
3814−#if CONFIG_VIDEOTOOLBOX
3815− { "videotoolbox_pixfmt", HAS_ARG | OPT_STRING | OPT_EXPERT, { &videotoolbox_pixfmt}, "" },
3816−#endif
38173797 { "hwaccels", OPT_EXIT, { .func_arg = show_hwaccels },
38183798 "show available HW acceleration methods" },
38193799 { "autorotate", HAS_ARG | OPT_BOOL | OPT_SPEC |
fftools/ffmpeg_videotoolbox.c+0−177
@@ -1,177 +0,0 @@
1−/*
2− * This file is part of FFmpeg.
3− *
4− * FFmpeg is free software; you can redistribute it and/or
5− * modify it under the terms of the GNU Lesser General Public
6− * License as published by the Free Software Foundation; either
7− * version 2.1 of the License, or (at your option) any later version.
8− *
9− * FFmpeg is distributed in the hope that it will be useful,
10− * but WITHOUT ANY WARRANTY; without even the implied warranty of
11− * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12− * Lesser General Public License for more details.
13− *
14− * You should have received a copy of the GNU Lesser General Public
15− * License along with FFmpeg; if not, write to the Free Software
16− * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17− */
18−
19−#include "config.h"
20−
21−#if HAVE_UTGETOSTYPEFROMSTRING
22−#include <CoreServices/CoreServices.h>
23−#endif
24−
25−#include "libavcodec/avcodec.h"
26−#include "libavcodec/videotoolbox.h"
27−#include "libavutil/imgutils.h"
28−#include "ffmpeg.h"
29−
30−typedef struct VTContext {
31− AVFrame *tmp_frame;
32− int log_once;
33−} VTContext;
34−
35−char *videotoolbox_pixfmt;
36−
37−static int videotoolbox_retrieve_data(AVCodecContext *s, AVFrame *frame)
38−{
39− InputStream *ist = s->opaque;
40− VTContext *vt = ist->hwaccel_ctx;
41− CVPixelBufferRef pixbuf = (CVPixelBufferRef)frame->data[3];
42− OSType pixel_format = CVPixelBufferGetPixelFormatType(pixbuf);
43− CVReturn err;
44− uint8_t *data[4] = { 0 };
45− int linesize[4] = { 0 };
46− int planes, ret, i;
47−
48− if (frame->format == ist->hwaccel_output_format) {
49− av_log_once(s, AV_LOG_INFO, AV_LOG_TRACE, &vt->log_once,
50− "There is no video filter for videotoolbox pix_fmt now, remove the "
51− "-hwaccel_output_format option if video filter doesn't work\n");
52− return 0;
53− }
54−
55− av_frame_unref(vt->tmp_frame);
56−
57− switch (pixel_format) {
58− case kCVPixelFormatType_420YpCbCr8Planar: vt->tmp_frame->format = AV_PIX_FMT_YUV420P; break;
59− case kCVPixelFormatType_422YpCbCr8: vt->tmp_frame->format = AV_PIX_FMT_UYVY422; break;
60− case kCVPixelFormatType_32BGRA: vt->tmp_frame->format = AV_PIX_FMT_BGRA; break;
61−#ifdef kCFCoreFoundationVersionNumber10_7
62− case kCVPixelFormatType_420YpCbCr8BiPlanarVideoRange:
63− case kCVPixelFormatType_420YpCbCr8BiPlanarFullRange: vt->tmp_frame->format = AV_PIX_FMT_NV12; break;
64−#endif
65−#if HAVE_KCVPIXELFORMATTYPE_420YPCBCR10BIPLANARVIDEORANGE
66− case kCVPixelFormatType_420YpCbCr10BiPlanarVideoRange:
67− case kCVPixelFormatType_420YpCbCr10BiPlanarFullRange: vt->tmp_frame->format = AV_PIX_FMT_P010; break;
68−#endif
69− default:
70− av_log(NULL, AV_LOG_ERROR,
71− "%s: Unsupported pixel format: %s\n",
72− av_fourcc2str(s->codec_tag), videotoolbox_pixfmt);
73− return AVERROR(ENOSYS);
74− }
75−
76− vt->tmp_frame->width = frame->width;
77− vt->tmp_frame->height = frame->height;
78− ret = av_frame_get_buffer(vt->tmp_frame, 0);
79− if (ret < 0)
80− return ret;
81−
82− err = CVPixelBufferLockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly);
83− if (err != kCVReturnSuccess) {
84− av_log(NULL, AV_LOG_ERROR, "Error locking the pixel buffer.\n");
85− return AVERROR_UNKNOWN;
86− }
87−
88− if (CVPixelBufferIsPlanar(pixbuf)) {
89−
90− planes = CVPixelBufferGetPlaneCount(pixbuf);
91− for (i = 0; i < planes; i++) {
92− data[i] = CVPixelBufferGetBaseAddressOfPlane(pixbuf, i);
93− linesize[i] = CVPixelBufferGetBytesPerRowOfPlane(pixbuf, i);
94− }
95− } else {
96− data[0] = CVPixelBufferGetBaseAddress(pixbuf);
97− linesize[0] = CVPixelBufferGetBytesPerRow(pixbuf);
98− }
99−
100− av_image_copy(vt->tmp_frame->data, vt->tmp_frame->linesize,
101− (const uint8_t **)data, linesize, vt->tmp_frame->format,
102− frame->width, frame->height);
103−
104− ret = av_frame_copy_props(vt->tmp_frame, frame);
105− CVPixelBufferUnlockBaseAddress(pixbuf, kCVPixelBufferLock_ReadOnly);
106− if (ret < 0)
107− return ret;
108−
109− av_frame_unref(frame);
110− av_frame_move_ref(frame, vt->tmp_frame);
111−
112− return 0;
113−}
114−
115−static void videotoolbox_uninit(AVCodecContext *s)
116−{
117− InputStream *ist = s->opaque;
118− VTContext *vt = ist->hwaccel_ctx;
119−
120− ist->hwaccel_uninit = NULL;
121− ist->hwaccel_retrieve_data = NULL;
122−
123− av_frame_free(&vt->tmp_frame);
124−
125− av_videotoolbox_default_free(s);
126− av_freep(&ist->hwaccel_ctx);
127−}
128−
129−int videotoolbox_init(AVCodecContext *s)
130−{
131− InputStream *ist = s->opaque;
132− int loglevel = (ist->hwaccel_id == HWACCEL_AUTO) ? AV_LOG_VERBOSE : AV_LOG_ERROR;
133− int ret = 0;
134− VTContext *vt;
135−
136− vt = av_mallocz(sizeof(*vt));
137− if (!vt)
138− return AVERROR(ENOMEM);
139−
140− ist->hwaccel_ctx = vt;
141− ist->hwaccel_uninit = videotoolbox_uninit;
142− ist->hwaccel_retrieve_data = videotoolbox_retrieve_data;
143−
144− vt->tmp_frame = av_frame_alloc();
145− if (!vt->tmp_frame) {
146− ret = AVERROR(ENOMEM);
147− goto fail;
148− }
149−
150− // TODO: reindent
151− if (!videotoolbox_pixfmt) {
152− ret = av_videotoolbox_default_init(s);
153− } else {
154− AVVideotoolboxContext *vtctx = av_videotoolbox_alloc_context();
155− CFStringRef pixfmt_str = CFStringCreateWithCString(kCFAllocatorDefault,
156− videotoolbox_pixfmt,
157− kCFStringEncodingUTF8);
158−#if HAVE_UTGETOSTYPEFROMSTRING
159− vtctx->cv_pix_fmt_type = UTGetOSTypeFromString(pixfmt_str);
160−#else
161− av_log(s, loglevel, "UTGetOSTypeFromString() is not available "
162− "on this platform, %s pixel format can not be honored from "
163− "the command line\n", videotoolbox_pixfmt);
164−#endif
165− ret = av_videotoolbox_default_init2(s, vtctx);
166− CFRelease(pixfmt_str);
167− }
168− if (ret < 0) {
169− av_log(NULL, loglevel, "Error creating Videotoolbox decoder.\n");
170− goto fail;
171− }
172−
173− return 0;
174−fail:
175− videotoolbox_uninit(s);
176− return ret;
177−}

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t