Hi, I've just started with libavformat usage and I'm using the out-example.c to kich off some tweaking. I decided to try and render libgd generated images into mpegs, an idea of Pierre Joye one of libgd's current maintainers. I was looking for any comment from people who have messed around a little with output-example.c on a problem: So I generate a TrueColor libgd image, and prepare a frame for it:
AVFrame *tmp_frame; // declares temporary frame
tmp_frame = alloc_picture(PIX_FMT_RGB24, 420, 300); // sets it up Then I assign RGB values from the libgd struct to the RGB triplet setup required by a PIX_FMT_RGB24 AVFrame:
for (y=0; y < 300; y++) {
 for (x=0; x < 420; x++) {
   for(int k=0;k<3;k++) {
     if(k==0)
tmp_frame->data[0][y*tmp_frame->linesize[0] + k*x +k]= ((gdim->tpixels[y][x] >> 16) & 0xff);
      else if(k==1)
tmp_frame->data[0][y*tmp_frame->linesize[0] + k*x +k]= ((gdim->tpixels[y][x] >> 8) & 0xff);
        else
tmp_frame->data[0][y*tmp_frame->linesize[0] + k*x +k]= (gdim->tpixels[y][x] & 0xff);
        }
  }
}
Then I need to convert to YUV420P, so I set up a SwsContext:
static struct SwsContext *gdimg_convert_ctx;
gdimg_convert_ctx = sws_getContext(420, 300, PIX_FMT_RGB24, 420, 300, PIX_FMT_YUV420P, sws_flags, NULL, NULL, NULL);
Then I carry out the conversion:
sws_scale(gdimg_convert_ctx, tmp_frame->data, tmp_frame->linesize, 0, 300, pict->data, pict->linesize); This (pict) then is returned to the write_video_frame function So this compiled and executes without segfaults, but the image is distorted. Only the the first half of the columns in the image are used. The image is also further squeezed and gets half-repeated within these first 210 columns. I.e. pretty messed up. Are there any potential gotchas in my simplistic conversion? I don't expect anybody to see the problem immediately, just looking for comments from people who may have some something similar. I've been going over imgconvert.c to get some clues as to what's going on also, but no insights quite yet.
Many thanks!
_______________________________________________
libav-user mailing list
[email protected]
https://lists.mplayerhq.hu/mailman/listinfo/libav-user

Reply via email to