On Tue, Nov 08, 2011 at 10:40:42PM +0100, Sebastien Zwickert wrote:
>
> In vda.h, I undefined Picture after the inclusion of VDADecoder.h (Picture
> struct is redefined in QD.h
> which get included from VDADecoder.h).
> Unfortunately, I have no better workaround for the emmintrin.h and gcc-4.2.1
> issue. (emmintrin.h get
> included from VDADecoder.h).
I have no better idea myself although I must say it's quite ugly :-(
> I tested the patch with these configure lines :
> ./configure --disable-everything --enable-vda
> ./configure --disable-everything --enable-hwaccel=vda
Was vda listed as enabled hwaccel in these configurations?
> --- /dev/null
> +++ b/libavcodec/vda.c
> @@ -0,0 +1,291 @@
> +
> +#include <CoreFoundation/CFDictionary.h>
> +#include <CoreFoundation/CFNumber.h>
> +#include <CoreFoundation/CFData.h>
> +#include <CoreFoundation/CFString.h>
> +
> +#include <pthread.h>
> +#include "vda_internal.h"
#include <CoreFoundation/CFDictionary.h>
#include <CoreFoundation/CFNumber.h>
#include <CoreFoundation/CFData.h>
#include <CoreFoundation/CFString.h>
#include <pthread.h>
#include "vda_internal.h"
> +/* helper to create a dictionary according to the given pts */
> +static CFDictionaryRef vda_dictionary_with_pts(int64_t i_pts)
> +{
> + CFStringRef key = CFSTR("FF_VDA_DECODER_PTS_KEY");
> + CFNumberRef value = CFNumberCreate(kCFAllocatorDefault,
> + kCFNumberSInt64Type, &i_pts);
> + CFDictionaryRef user_info = CFDictionaryCreate(kCFAllocatorDefault,
> + (const void **)&key,
> + (const void **)&value,
> + 1,
> +
> &kCFTypeDictionaryKeyCallBacks,
> +
> &kCFTypeDictionaryValueCallBacks);
Are the void** casts necessary?
> +/* Decoder callback that adds the VDA frame to the queue in display order. */
> +static void vda_decoder_callback(void *vda_hw_ctx,
> + CFDictionaryRef user_info,
> + OSStatus status,
> + uint32_t infoFlags,
> + CVImageBufferRef image_buffer)
> +{
> +
> + new_frame = av_mallocz(sizeof(vda_frame));
> + new_frame->next_frame = NULL;
> + new_frame->cv_buffer = CVPixelBufferRetain(image_buffer);
> + new_frame->pts = vda_pts_from_dictionary(user_info);
Are you sure this malloc will always succeed?
> + if (!queue_walker || (new_frame->pts < queue_walker->pts)) {
Pointless (), but make sure gcc adds no warnings if you drop them.
> + /* we have an empty queue, or this frame earlier than the current
> queue head */
is earlier?
> + if (!next_frame || (new_frame->pts < next_frame->pts)) {
see above
> + buffer_attributes = (CFDictionaryCreateMutable(kCFAllocatorDefault,
> + 2,
> +
> &kCFTypeDictionaryKeyCallBacks,
> +
> &kCFTypeDictionaryValueCallBacks));
> + io_surface_properties = (CFDictionaryCreateMutable(kCFAllocatorDefault,
> + 0,
> +
> &kCFTypeDictionaryKeyCallBacks,
> +
> &kCFTypeDictionaryValueCallBacks));
pointless ()
> + cv_pix_fmt_type = kCVPixelFormatType_422YpCbCr8;
> + cv_pix_fmt = CFNumberCreate(kCFAllocatorDefault,
> + kCFNumberSInt32Type,
> &cv_pix_fmt_type);
Indentation is off.
> + CFDictionarySetValue(buffer_attributes,
> kCVPixelBufferPixelFormatTypeKey, cv_pix_fmt);
> + CFDictionarySetValue(buffer_attributes,
> + kCVPixelBufferIOSurfacePropertiesKey,
> io_surface_properties);
These long lines you could break easily.
> + status = VDADecoderCreate(config_info,
> + buffer_attributes,
> + (VDADecoderOutputCallback
> *)vda_decoder_callback,
> + (void *)vda_ctx,
> + &vda_ctx->decoder );
stray space before )
Is the void* cast necessary?
> --- /dev/null
> +++ b/libavcodec/vda_h264.c
> @@ -0,0 +1,110 @@
> +
> +static int end_frame(AVCodecContext *avctx)
> +{
> + H264Context *h = avctx->priv_data;
> + struct vda_context *vda_ctx = avctx->hwaccel_context;
> + struct vda_picture_context *pic_ctx =
> h->s.current_picture_ptr->f.hwaccel_picture_private;
> + AVFrame *frame = (AVFrame*)h->s.current_picture_ptr;
Please try instead:
AVFrame *frame = &h->s.current_picture_ptr.f;
> --- /dev/null
> +++ b/libavcodec/vda_internal.h
> @@ -0,0 +1,42 @@
> +
> +#include "vda.h"
#include <stdint.h>
#include "vda.h"
> +/** Send a frame data to the hardware decoder. */
> +int ff_vda_decoder_decode(struct vda_context *vda_ctx,
> + uint8_t *bitstream,
> + int bitstream_size,
> + int64_t frame_pts);
What are you sending? "A frame" or "data"? There is no such thing as
"a data" since "data" has no plural.
Diego
_______________________________________________
libav-devel mailing list
[email protected]
https://lists.libav.org/mailman/listinfo/libav-devel