Thomas Seilund wrote:
Dear all,

I have a filled out AVFrame and an image buffer.

The AVFrame holds a video frame, yuv420p, 720x576.

The image buffer is an RGB24, 88x90.

I want to substitute the upper left corner of the AVFrame with the content of the image buffer.

I have the following code where picture is my AVFrame and image_blob is my image buffer. Basically I put every third byte of the image buffer into AVFrame->data[0].

  offsetSB = 0;
  pipw = 88;
  piph = 90;
  for (line = 0; line < 1; line++)
  {
      for (hTPS = 0; hTPS < piph; hTPS++) {
          for (wTPS = 0; wTPS < pipw; wTPS++) {
picture->data[line][hTPS * picture->linesize[line] + wTPS] =
                  *(image_blob + 3*offsetSB++);
          }
      }
  }

This works fine but I only get a black and white image buffer in the upper left part of the AVFrame.

I simply don't know how to get the colors of the image buffer into the AFFrame as well.

Any help would be very much appreciated.

Thanks

Thomas S

_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user
Hi all

SOLVED.

1. I use an ImageMagick function to convert image buffer from RGB24 to YUV
2. I set up a new AVFrame that holds my image buffer using function avpicture_fill() - new frame is pFrameRGB
3. Then I change the loop this way:

   offsetSB = 0;
   int line;
   for (line = 0; line < 4; line++)
   {
       for (hTPS = 0; hTPS < piph / (line ? 2 : 1); hTPS++) {
           for (wTPS = 0; wTPS < pFrameRGB->linesize[line]; wTPS++) {
picture->data[line][(hTPS + fromTop) * picture->linesize[line] + wTPS + fromLeft] = pFrameRGB->data[line][hTPS * pFrameRGB->linesize[line] + wTPS];
           }
       }
   }

I have added a few variables, fromTop and fromLeft.The intention is that I should be able to move the inserted image buffer around in the larger AVFrame.

Thanks

Thomas S
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to