56static int compare(
const void *a,
const void *b,
void *ctx) {
58 int bits_per_comp = ((
const AVPixFmtDescriptor *) ctx)->comp[0].depth;
59 int deptha = av_pix_fmt_desc_get(*(
const enum AVPixelFormat*) a)->comp[0].depth;
60 int depthb = av_pix_fmt_desc_get(*(
const enum AVPixelFormat*) b)->comp[0].depth;
61 if (deptha != depthb) {
63 if (deptha < bits_per_comp || depthb < bits_per_comp) {
64 return depthb - deptha;
67 return deptha - depthb;
86 AVBufferRef *device_ref = NULL;
87 int ret = create_hw_device_ctx(AV_HWDEVICE_TYPE_VIDEOTOOLBOX, &device_ref);
91 enum AVPixelFormat probe_formats[] = { s->sw_pix_fmt, AV_PIX_FMT_UYVY422,
97 sort_codecs(s->sw_pix_fmt,
sizeof probe_formats /
sizeof probe_formats[0] - 1, probe_formats + 1);
99 AVBufferRef *hw_frames_ctx = NULL;
100 for (
unsigned i = 0; i <
sizeof probe_formats /
sizeof probe_formats[0]; ++i) {
102 ret = create_hw_frame_ctx(device_ref,
105 AV_PIX_FMT_VIDEOTOOLBOX,
111 av_get_pix_fmt_name(probe_formats[i]));
119 AVFrame *
frame = av_frame_alloc();
129 s->hw_frames_ctx = hw_frames_ctx;
130 s->hw_device_ctx = device_ref;
135 av_frame_free(&
state->tmp_frame);
136 av_buffer_unref(&device_ref);
137 av_buffer_unref(&hw_frames_ctx);