fork download
  1. void VideoDecoder::DecodeThread()
  2. {
  3. AVPacket pkt;
  4. int len;
  5. uint8_t *data;
  6. int size;
  7. uint32_t h,w;
  8.  
  9. if(!_pkt_queue->Pop(&pkt))
  10. return;
  11.  
  12. data = pkt.data;
  13. size = pkt.size;
  14.  
  15. _pkt_pts = pkt.pts *_video_stream->time_base.num*1000/_video_stream->time_base.den;
  16.  
  17. int got_frame;
  18.  
  19. while (pkt.size > 0)
  20. {
  21. len = avcodec_decode_video2(_video_stream->codec,_av_frame,&got_frame,&pkt);
  22. if (len < 0)
  23. {
  24. LOG "invalid video packet or frame. Skipping packet" EL;
  25. break;
  26. }
  27.  
  28. if (got_frame!=0)
  29. {
  30. VideoFrame video_frame;
  31.  
  32. h = _video_stream->codec->height;
  33. w = _video_stream->codec->width;
  34.  
  35. video_frame.y = fast_alloc(uint8_t,h*w);
  36. video_frame.u = fast_alloc(uint8_t,h*w/4);
  37. video_frame.v = fast_alloc(uint8_t,h*w/4);
  38.  
  39. WritePlane(_av_frame->data[0],_av_frame->linesize[0],w,h,video_frame.y);
  40. WritePlane(_av_frame->data[1],_av_frame->linesize[1],w/2,h/2,video_frame.u);
  41. WritePlane(_av_frame->data[2],_av_frame->linesize[2],w/2,h/2,video_frame.v);
  42.  
  43. video_frame.pts = _pkt_pts;
  44. _pkt_pts += GetFramerateDelay();
  45.  
  46. if (!_frame_queue->Push(video_frame))
  47. {
  48. fast_free(video_frame.y);
  49. fast_free(video_frame.u);
  50. fast_free(video_frame.v);
  51. av_free_packet(&pkt);
  52. return;
  53. }
  54. }
  55.  
  56. pkt.size -= len;
  57. pkt.data += len;
  58. }
  59.  
  60. pkt.data = data;
  61. pkt.size = size;
  62.  
  63. av_free_packet(&pkt);
  64. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
prog.cpp:1:6: error: ‘VideoDecoder’ has not been declared
prog.cpp: In function ‘void DecodeThread()’:
prog.cpp:3:5: error: ‘AVPacket’ was not declared in this scope
prog.cpp:3:14: error: expected ‘;’ before ‘pkt’
prog.cpp:5:2: error: ‘uint8_t’ was not declared in this scope
prog.cpp:5:11: error: ‘data’ was not declared in this scope
prog.cpp:7:2: error: ‘uint32_t’ was not declared in this scope
prog.cpp:7:11: error: expected ‘;’ before ‘h’
prog.cpp:9:6: error: ‘_pkt_queue’ was not declared in this scope
prog.cpp:9:23: error: ‘pkt’ was not declared in this scope
prog.cpp:12:9: error: ‘pkt’ was not declared in this scope
prog.cpp:15:2: error: ‘_pkt_pts’ was not declared in this scope
prog.cpp:15:22: error: ‘_video_stream’ was not declared in this scope
prog.cpp:21:52: error: ‘_av_frame’ was not declared in this scope
prog.cpp:21:77: error: ‘avcodec_decode_video2’ was not declared in this scope
prog.cpp:24:5: error: ‘LOG’ was not declared in this scope
prog.cpp:24:10: error: expected ‘;’ before string constant
prog.cpp:30:5: error: ‘VideoFrame’ was not declared in this scope
prog.cpp:30:16: error: expected ‘;’ before ‘video_frame’
prog.cpp:32:5: error: ‘h’ was not declared in this scope
prog.cpp:33:5: error: ‘w’ was not declared in this scope
prog.cpp:35:5: error: ‘video_frame’ was not declared in this scope
prog.cpp:35:43: error: ‘fast_alloc’ was not declared in this scope
prog.cpp:39:75: error: ‘WritePlane’ was not declared in this scope
prog.cpp:44:47: error: ‘GetFramerateDelay’ was not declared in this scope
prog.cpp:46:10: error: ‘_frame_queue’ was not declared in this scope
prog.cpp:48:29: error: ‘fast_free’ was not declared in this scope
prog.cpp:51:25: error: ‘av_free_packet’ was not declared in this scope
prog.cpp:63:21: error: ‘av_free_packet’ was not declared in this scope
stdout
Standard output is empty