title: How to decode a H.264 frame on iOS by hardware decoding?
body: <p>I have been used ffmpeg to decode every single frame that I received from my ip cam. The brief code looks like this:</p>
  
  <pre><code>-(void) decodeFrame:(unsigned char *)frameData frameSize:(int)frameSize{
     AVFrame frame;
     AVPicture picture;
     AVPacket pkt;
     AVCodecContext *context;
     pkt.data = frameData;
     pat.size = frameSize;
     avcodec_get_frame_defaults(&amp;frame);
     avpicture_alloc(&amp;picture, PIX_FMT_RGB24, targetWidth, targetHeight);
     avcodec_decode_video2(&amp;context, &amp;frame, &amp;got_picture, &amp;pkt);
  }
  </code></pre>
  
  <p>The code woks fine, but it's software decoding. I want to enhance the decoding performance by hardware decoding. After lots of research, I know it may be achieved by AVFoundation framework. 
  The AVAssetReader class may help, but I can't figure out what's the next.Could anyone points out the following steps for me? Any help would be appreciated.</p>