mp_image: allow passing NULL to mp_image_new_custom_ref()

A minor simplification. Most callers don't need this, and there's no
good reason why the caller should provide an "initializer" like this.
(This function calls mp_image_new_dummy_ref(), which has no reason
for an initializer either.)
This commit is contained in:
wm4 2016-04-25 11:28:49 +02:00
parent e232f1a731
commit 021cb2c387
5 changed files with 7 additions and 9 deletions

View File

@ -69,8 +69,8 @@ struct mp_image *d3d11va_new_ref(ID3D11VideoDecoderOutputView *view,
ID3D11VideoDecoderOutputView_GetResource( ID3D11VideoDecoderOutputView_GetResource(
surface->surface, (ID3D11Resource **)&surface->texture); surface->surface, (ID3D11Resource **)&surface->texture);
struct mp_image *mpi = mp_image_new_custom_ref( struct mp_image *mpi =
&(struct mp_image){0}, surface, d3d11va_release_img); mp_image_new_custom_ref(NULL, surface, d3d11va_release_img);
if (!mpi) if (!mpi)
abort(); abort();

View File

@ -72,8 +72,8 @@ struct mp_image *dxva2_new_ref(IDirectXVideoDecoder *decoder,
surface->decoder = decoder; surface->decoder = decoder;
IDirectXVideoDecoder_AddRef(surface->decoder); IDirectXVideoDecoder_AddRef(surface->decoder);
struct mp_image *mpi = mp_image_new_custom_ref(&(struct mp_image){0}, struct mp_image *mpi =
surface, dxva2_release_img); mp_image_new_custom_ref(NULL, surface, dxva2_release_img);
if (!mpi) if (!mpi)
abort(); abort();

View File

@ -230,7 +230,7 @@ struct mp_image *mp_image_new_dummy_ref(struct mp_image *img)
{ {
struct mp_image *new = talloc_ptrtype(NULL, new); struct mp_image *new = talloc_ptrtype(NULL, new);
talloc_set_destructor(new, mp_image_destructor); talloc_set_destructor(new, mp_image_destructor);
*new = *img; *new = img ? *img : (struct mp_image){0};
for (int p = 0; p < MP_MAX_PLANES; p++) for (int p = 0; p < MP_MAX_PLANES; p++)
new->bufs[p] = NULL; new->bufs[p] = NULL;
new->hwctx = NULL; new->hwctx = NULL;

View File

@ -435,8 +435,7 @@ static void draw_frame(struct vo *vo, struct vo_frame *frame)
} }
mmal_buffer_header_reset(buffer); mmal_buffer_header_reset(buffer);
struct mp_image *new_ref = mp_image_new_custom_ref(&(struct mp_image){0}, struct mp_image *new_ref = mp_image_new_custom_ref(NULL, buffer,
buffer,
free_mmal_buffer); free_mmal_buffer);
if (!new_ref) { if (!new_ref) {
mmal_buffer_header_release(buffer); mmal_buffer_header_release(buffer);

View File

@ -268,8 +268,7 @@ static struct mp_image *create_ref(struct mp_vdpau_ctx *ctx, int index)
struct surface_ref *ref = talloc_ptrtype(NULL, ref); struct surface_ref *ref = talloc_ptrtype(NULL, ref);
*ref = (struct surface_ref){ctx, index}; *ref = (struct surface_ref){ctx, index};
struct mp_image *res = struct mp_image *res =
mp_image_new_custom_ref(&(struct mp_image){0}, ref, mp_image_new_custom_ref(NULL, ref, release_decoder_surface);
release_decoder_surface);
if (res) { if (res) {
mp_image_setfmt(res, e->rgb ? IMGFMT_VDPAU_OUTPUT : IMGFMT_VDPAU); mp_image_setfmt(res, e->rgb ? IMGFMT_VDPAU_OUTPUT : IMGFMT_VDPAU);
mp_image_set_size(res, e->w, e->h); mp_image_set_size(res, e->w, e->h);