Advertisement
Guest User

Untitled

a guest
May 23rd, 2017
60
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* previously defined
  2. #define FRAME_WIDTH  320
  3. #define FRAME_HEIGHT 480
  4. */
  5.  
  6. uint8_t *rgb_data = buffer + (frameSize * ((*totalCaptured - 1) % BUFFER_FRAME_MAX_COUNT));
  7.  
  8. uint8_t *rgb_src[3] = {
  9.     rgb_data,
  10.     NULL,
  11.     NULL
  12. };
  13.  
  14. int rgb_stride[3] = {
  15.     4 * FRAME_WIDTH,
  16.     0,
  17.     0
  18. };
  19.  
  20. uint8_t *src[4] = {
  21.     scaleBuffer,
  22.     scaleBuffer + FRAME_WIDTH * FRAME_HEIGHT,
  23.     scaleBuffer + ( FRAME_WIDTH * FRAME_HEIGHT ) + ( FRAME_WIDTH * FRAME_HEIGHT / 4 ),
  24.     NULL
  25. };
  26.  
  27. int stride[4] = {
  28.     FRAME_WIDTH,
  29.     FRAME_WIDTH / 2,
  30.     FRAME_WIDTH / 2,
  31.     0
  32. };
  33.  
  34. struct SwsContext *sws;
  35.  
  36. sws = sws_getContext(FRAME_WIDTH,       // src width
  37.                      FRAME_HEIGHT,      // src height
  38.                      PIX_FMT_RGB32,     // src pixel format ,
  39.                      FRAME_WIDTH,       // dest width
  40.                      FRAME_HEIGHT,      // dest height
  41.                      PIX_FMT_YUV420P,   // dest pix format
  42.                      SWS_BILINEAR,      // FLAGS
  43.                      NULL,  
  44.                      NULL,
  45.                      NULL);
  46.  
  47.  
  48. int sliceHeight = sws_scale(sws,
  49.                             rgb_src,
  50.                             rgb_stride,
  51.                             0,
  52.                             FRAME_HEIGHT,
  53.                             src,
  54.                             stride);
  55.                            
  56. // the "sliceHeight" variable evaluates to 480 in GDB at this point, which seems correct
  57.  
  58. if (sliceHeight <= 0)
  59. {
  60.     NSLog(@"couldn't scale");
  61.     abort();
  62. }
  63.  
  64. sws_freeContext(sws);
  65.  
  66. currentPicture->data[0] = src[0];
  67. currentPicture->data[1] = src[1];
  68. currentPicture->data[2] = src[2];
  69. currentPicture->data[3] = src[3];
  70.  
  71. currentPicture->linesize[0] = stride[0];
  72. currentPicture->linesize[1] = stride[1];
  73. currentPicture->linesize[2] = stride[2];
  74. currentPicture->linesize[3] = stride[3];
  75.  
  76. int out_size = avcodec_encode_video(codecContext, encodeBuffer, frameSize, currentPicture);
  77.  
  78. // the "out_size" variable evaluates to 4 in GDB, which seems incorrect
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement