Yay! I got it working.
It is strange, though... if I do this in the filter's frame routine:

//vY = ptr->video_buf_Y
//vU = ptr->video_buf_U
//vV = ptr->video_buf_V
for(y=0; y<256; y++) {
  for(x=0; x<256; x++) {
    vY[0][y*w + x] = 128;
    vY[1][y*w + x] = 128;
    if(y%2==0 && x%2==0) {
      vU[0][(y*w)/4 + x/2] = x;
      vU[1][(y*w)/4 + x/2] = x;
      vV[0][(y*w)/4 + x/2] = y;
      vV[1][(y*w)/4 + x/2] = y;
    }
  }
}

(i.e. to print out a square that has the whole colour space in it, at Y=128 (middle of the range), basically it's a graph with the x axis being U, and y axis being V), the result looks like the UV colour plane shown at wikipedia:
http://en.wikipedia.org/wiki/YUV
(at the top of the page, on the right) EXCEPT for one big difference; the colour plane I generated is rotated 90 degrees clockwise. In other words, it looks to me like ***the U and V components are swapped***. I don't know why that is... if any of you do know, I'd love to have an explanation, or a link to some document that explains it... but the whole thing works for me now, after I simply swapped the U and V components... i.e. doing this conversion:

Y = 0.299*R + 0.587*G + 0.114*B;
V = (B-Y)*0.565;
U = (R-Y)*0.713;

Instead of this:

Y = 0.299*R + 0.587*G + 0.114*B;
U = (B-Y)*0.565;
V = (R-Y)*0.713;


So now the only question is, is anyone else interested in a version of the extsub filter which takes as three of its arguments the R, G, and B values you want the subtitle to be rendered in? :-)

It's not what I'd call "fully tested" or "fully featured" yet, but it works for me, so I figured it might be useful for others. If the already existing extsub filter has colour control (i.e. so you can select what colour the final subtitle will be), then ignore this, but I couldn't figure out for the life of me how to use extsub's colour selection (if it has any.. and I didn't see much in the code to indicate that it does, either), so I coded my own version.

Basically, with my version, you can now do this:

-J extsub=0:0:0:1:0:255:255:255:4:0

The first 5 arguments are as they were before, but now the 6th, 7th, and 8th arguments specify the R, G, and B values for the subtitle to be coloured with. So, in this example, the subtitle would be white. The 9th argument is the edge style; I've made it so you can add a drop shadow to the subtitle, or leave it as is, plus a couple of other options in between (edge thickness, basically). Range is 0 to 4 inclusive. The final argument is a brightness adjustment; -256 to 256 inclusive, it is added to the Y component of the final subtitle in order to make the colour brighter or darker. It shouldn't be needed, but in case it is, it's there.

If anyone is interested, let me know, and let me know where to send the filter_extsub.c file so you can take a look at it!

(If it will work to post it here I can do that, but I don't know if it will get messed up when I paste it into an email? Like, it might wrap long lines, or something, I don't know...)

--

James G. Flewelling,
Registered Linux User #327359
Linux From Scratch User #15607

Reply via email to