<div dir="ltr"><div><span class="" style="white-space:pre">During Init.....</span></div><div><span class="" style="white-space:pre"><br></span></div><div><span class="" style="white-space:pre"><br></span></div><div><span class="" style="white-space:pre">                  </span>file->pVideoFrameRGB = ffmpeg.av_frame_alloc();</div>
<div><span class="" style="white-space:pre">                    </span>{</div><div><span class="" style="white-space:pre">                          </span>int num_bytes;</div><div>#ifdef WIN32</div><div>#define PIX_FMT  PIX_FMT_BGRA</div><div>#else</div><div>#define PIX_FMT  PIX_FMT_RGBA</div>
<div>#endif</div><div><span class="" style="white-space:pre">                               </span>num_bytes = ffmpeg.avpicture_get_size(PIX_FMT, file->pVideoCodecCtx->width, file->pVideoCodecCtx->height);</div><div><span class="" style="white-space:pre">                             </span>file->rgb_buffer = (_8 *)ffmpeg.av_malloc(num_bytes*sizeof(uint8_t));</div>
<div><span class="" style="white-space:pre">                            </span>ffmpeg.avpicture_fill((AVPicture*)file->pVideoFrameRGB, file->rgb_buffer, PIX_FMT</div><div><span class="" style="white-space:pre">                                    </span>, file->pVideoCodecCtx->width, file->pVideoCodecCtx->height);</div>
<div><span class="" style="white-space:pre">                    </span>}</div><div><span class="" style="white-space:pre">                  </span>file->img_convert_ctx = ffmpeg.sws_getContext(file->pVideoCodecCtx->width, file->pVideoCodecCtx->height</div>
<div><span class="" style="white-space:pre">                            </span>, file->pVideoCodecCtx->pix_fmt </div><div><span class="" style="white-space:pre">                             </span>, file->pVideoCodecCtx->width, file->pVideoCodecCtx->height</div>
<div><span class="" style="white-space:pre">                            </span>, PIX_FMT, SWS_BICUBIC, NULL, NULL, NULL);</div><div><br></div><div><br></div><div><br></div><div>// CDATA is _32 color data in my library, image surface is the raw out RGB</div>
<div><br></div><div><div><span class="" style="white-space:pre">                                                </span>CDATA *surface = GetImageSurface( out_surface );</div><div><span class="" style="white-space:pre">                                           </span>ffmpeg.sws_scale(file->img_convert_ctx</div>
<div><span class="" style="white-space:pre">                                                    </span>, (const uint8_t*const*)file->pVideoFrame->data, file->pVideoFrame->linesize</div><div><span class="" style="white-space:pre">                                                   </span>, 0, file->pVideoCodecCtx->height</div>
<div><span class="" style="white-space:pre">                                                    </span>, file->pVideoFrameRGB->data</div><div><span class="" style="white-space:pre">                                                 </span>, file->pVideoFrameRGB->linesize);</div></div><div><br></div>
<div>// depending on target platform, the image needs to be 'flipped' on output from the pVideoFrameRGB</div><div><div><span class="" style="white-space:pre">                                                </span>{</div><div>#ifdef _INVERT_IMAGE</div><div>
<span class="" style="white-space:pre">                                                       </span>int row;</div><div><span class="" style="white-space:pre">                                                   </span>for( row = 0; row < file->pVideoFrame->height; row++ )</div><div><span class="" style="white-space:pre">                                                    </span>{</div>
<div><span class="" style="white-space:pre">                                                            </span>memcpy( surface + ( file->pVideoFrame->height - row - 1 ) * file->pVideoFrame->width</div><div><span class="" style="white-space:pre">                                                                   </span>, file->rgb_buffer + row * sizeof(CDATA) * file->pVideoFrame->width, file->pVideoFrame->width * sizeof( CDATA ) );</div>
<div><span class="" style="white-space:pre">                                                    </span>}</div><div>#else</div><div><span class="" style="white-space:pre">                                                      </span>memcpy( surface </div><div><span class="" style="white-space:pre">                                                           </span>, file->rgb_buffer , file->pVideoFrame->height * file->pVideoFrame->width * sizeof( CDATA ) );</div>
<div>#endif</div><div><span class="" style="white-space:pre">                                               </span>}</div></div><div><br></div><div><br></div><div>// Output surface to display</div></div><div class="gmail_extra"><br><br><div class="gmail_quote">On Mon, Mar 10, 2014 at 6:11 PM, Ricky Huang <span dir="ltr"><<a href="mailto:rhuang.work@gmail.com" target="_blank">rhuang.work@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><div class=""><div>On Mar 10, 2014, at 4:28 PM, J Decker <<a href="mailto:d3ck0r@gmail.com" target="_blank">d3ck0r@gmail.com</a>> wrote:</div>
<br><blockquote type="cite"><div dir="ltr"><span style="white-space:pre-wrap">I would think you would just use 'sws_getContext' and 'sws_scale'</span><div><span style="white-space:pre-wrap">worked good for me... </span></div>
</div></blockquote><div><br></div></div>Thank you for the pointer.  May I have a little more info regarding how you used <span style="white-space:pre-wrap">sws_getContext()?  I found its API definition as follows:</span></div>
<div><br></div><div><span style="white-space:pre-wrap">struct SwsContext * <span style="white-space:pre-wrap">  </span>sws_getContext (int srcW, int srcH, enum PixelFormat srcFormat, int dstW, int dstH, enum PixelFormat dstFormat, int flags, SwsFilter *srcFilter, SwsFilter *dstFilter, const double *param)</span><br>
<div><br></div><div>and it allocates and returns a <span style="white-space:pre-wrap">struct</span><span style="white-space:pre-wrap"> </span><span style="white-space:pre-wrap">SwsContext*.</span></div><div><span style="white-space:pre-wrap"><br>
</span></div><div>In my case I am not modifying anything in my filter, why is this function good for me? (I am assuming this performs some kind of transformation because there's a source and destination).  Also in the returned SwsContext struct, I see there are 4 members:</div>
<div><br></div><div>int <span style="white-space:pre-wrap">     </span>lumXInc</div><div>int <span style="white-space:pre-wrap">      </span>chrXInc<br>int <span style="white-space:pre-wrap">   </span>lumYInc<br>int <span style="white-space:pre-wrap">   </span>chrYInc<br>
<br></div><div>perhaps this is where I can get the luminance?  In that case, does it mean I have to perform some kind of transformation before even able to get the Context?</div><div><br></div><div><br></div><div>Thank you for in advance for clarification.</div>
<div><div class="h5"><div><br></div><div><br></div><br><blockquote type="cite"><div class="gmail_extra"><div class="gmail_quote">On Mon, Mar 10, 2014 at 4:18 PM, Ricky Huang <span dir="ltr"><<a href="mailto:rhuang.work@gmail.com" target="_blank">rhuang.work@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
<div style="word-wrap:break-word">Hello all,<div><br></div><div>I am writing code that extracts the luminance component of an input video using my own custom filter in libavfilter - specifically I am extracting it from "PIX_FMT_YUV420P" a video and I am wondering how to go about doing so.  According to the pixfmt.h header: </div>

<div><blockquote type="cite"><br></blockquote><blockquote type="cite">PIX_FMT_YUV420P,   ///< planar YUV 4:2:0, 12bpp, (1 Cr & Cb sample per 2x2 Y samples)</blockquote><br></div><div>I am not sure how to interpret that.  Assuming I am doing this in my draw_slice() function. It has the definition of:</div>

<div></div><blockquote type="cite"><div><br></div><div>static void draw_slice(AVFilterLink *inlink, int y0, int h, int slice_dir)</div></blockquote><div><br></div><div>I know I can get to the input data plane by:</div><div>

</div><blockquote type="cite"><div><br></div><div>AVFilterBufferRef *cur_pic = link->cur_buf;</div><div>uint8_t *data = cur_pic->data[0];</div></blockquote><br><div>But there are multiple "planes" in the data.  Does data[0], data[1], data[2] correspond to each of the Y, U, V channels?</div>

<div><br></div><div>Also, once I am able to point my pointer at the correct coordinate, how should I interpret the extracted result (float, int, etc)?</div><div><br></div><div><br></div><div>Thank you in advance.</div></div>

<br>_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br></blockquote></div><br></div>
_______________________________________________<br>Libav-user mailing list<br><a href="mailto:Libav-user@ffmpeg.org" target="_blank">Libav-user@ffmpeg.org</a><br><a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
</blockquote></div></div></div><br></div><br>_______________________________________________<br>
Libav-user mailing list<br>
<a href="mailto:Libav-user@ffmpeg.org">Libav-user@ffmpeg.org</a><br>
<a href="http://ffmpeg.org/mailman/listinfo/libav-user" target="_blank">http://ffmpeg.org/mailman/listinfo/libav-user</a><br>
<br></blockquote></div><br></div>