r23039 - in trunk/libavfilter: vsrc_buffer.c vsrc_buffer.h
Author: michael Date: Fri May 7 03:25:00 2010 New Revision: 23039 Log: Add "Memory buffer source filter" from SOC. This is needed by the current SOC-ffmpeg.c code. Added: trunk/libavfilter/vsrc_buffer.c trunk/libavfilter/vsrc_buffer.h Added: trunk/libavfilter/vsrc_buffer.c ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/libavfilter/vsrc_buffer.c Fri May 7 03:25:00 2010 (r23039) @@ -0,0 +1,140 @@ +/* + * Memory buffer source filter + * Copyright (c) 2008 Vitor Sessak + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +#include "avfilter.h" +#include "vsrc_buffer.h" + +typedef struct { + int64_t pts; + AVFrame frame; + int has_frame; + int h, w, pix_fmt; + AVRational pixel_aspect; +} BufferSourceContext; + + +int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, + int64_t pts, AVRational pixel_aspect) +{ + BufferSourceContext *c = buffer_filter->priv; + + if (c->has_frame) { + av_log(buffer_filter, AV_LOG_ERROR, + "Buffering several frames is not supported. " + "Please consume all available frames before adding a new one.\n" + ); + //return -1; + } + + memcpy(c->frame.data , frame->data , sizeof(frame->data)); + memcpy(c->frame.linesize, frame->linesize, sizeof(frame->linesize)); + c->pts = pts; + c->pixel_aspect = pixel_aspect; + c->has_frame = 1; + + return 0; +} + +static av_cold int init(AVFilterContext *ctx, const char *args, void *opaque) +{ + BufferSourceContext *c = ctx->priv; + + if(args && sscanf(args, "%d:%d:%d", &c->w, &c->h, &c->pix_fmt) == 3) + return 0; + + av_log(ctx, AV_LOG_ERROR, "init() expected 3 arguments:'%s'\n", args); + return -1; +} + +static int query_formats(AVFilterContext *ctx) +{ + BufferSourceContext *c = ctx->priv; + enum PixelFormat pix_fmts[] = { c->pix_fmt, PIX_FMT_NONE }; + + avfilter_set_common_formats(ctx, avfilter_make_format_list(pix_fmts)); + return 0; +} + +static int config_props(AVFilterLink *link) +{ + BufferSourceContext *c = link->src->priv; + + link->w = c->w; + link->h = c->h; + + return 0; +} + + +static int request_frame(AVFilterLink *link) +{ + BufferSourceContext *c = link->src->priv; + AVFilterPicRef *picref; + + if (!c->has_frame) { + av_log(link->src, AV_LOG_ERROR, + "request_frame() called with no available frame!\n"); + //return -1; + } + + /* This picture will be needed unmodified later for decoding the next + * frame */ + picref = avfilter_get_video_buffer(link, AV_PERM_WRITE | AV_PERM_PRESERVE | + AV_PERM_REUSE2, + link->w, link->h); + + av_picture_copy((AVPicture *)&picref->data, (AVPicture *)&c->frame, + picref->pic->format, link->w, link->h); + + picref->pts = c->pts; + picref->pixel_aspect = c->pixel_aspect; + avfilter_start_frame(link, avfilter_ref_pic(picref, ~0)); + avfilter_draw_slice(link, 0, link->h, 1); + avfilter_end_frame(link); + avfilter_unref_pic(picref); + + c->has_frame = 0; + + return 0; +} + +static int poll_frame(AVFilterLink *link) +{ + BufferSourceContext *c = link->src->priv; + return !!(c->has_frame); +} + +AVFilter avfilter_vsrc_buffer = +{ + .name = "buffer", + .priv_size = sizeof(BufferSourceContext), + .query_formats = query_formats, + + .init = init, + + .inputs = (AVFilterPad[]) {{ .name = NULL }}, + .outputs = (AVFilterPad[]) {{ .name = "default", + .type = AVMEDIA_TYPE_VIDEO, + .request_frame = request_frame, + .poll_frame = poll_frame, + .config_props = config_props, }, + { .name = NULL}}, +}; Added: trunk/libavfilter/vsrc_buffer.h ============================================================================== --- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/libavfilter/vsrc_buffer.h Fri May 7 03:25:00 2010 (r23039) @@ -0,0 +1,24 @@ +/* + * Memory buffer source filter + * Copyright (c) 2008 Vitor Sessak + * + * This file is part of FFmpeg. + * + * FFmpeg is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; either + * version 2.1 of the License, or (at your option) any later version. + * + * FFmpeg is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + * Lesser General Public License for more details. + * + * You should have received a copy of the GNU Lesser General Public + * License along with FFmpeg; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, + int64_t pts, AVRational pixel_aspect); +
On Fri, May 07, 2010 at 03:25:00AM +0200, michael wrote:
Log: Add "Memory buffer source filter" from SOC. This is needed by the current SOC-ffmpeg.c code.
As usual you ignore certain requirements..
--- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/libavfilter/vsrc_buffer.h Fri May 7 03:25:00 2010 (r23039) @@ -0,0 +1,24 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, + int64_t pts, AVRational pixel_aspect);
..this is missing multiple inclusion guards and appropriate header #includes to pass 'make checkheaders'. Diego
On Thu, Jun 17, 2010 at 11:32:49AM +0200, Diego Biurrun wrote:
On Fri, May 07, 2010 at 03:25:00AM +0200, michael wrote:
Log: Add "Memory buffer source filter" from SOC. This is needed by the current SOC-ffmpeg.c code.
As usual you ignore certain requirements..
if they can be ignored they hardly could have been required That said this code is from soc and even if you prefer flaming me iam not the author of this file. And of course ive not ignored it but rather i concentrate on getting the code working properly not on things unrelated to code and developers interacting with code (mainntance & readability & so on) aka i forgot about it
--- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/libavfilter/vsrc_buffer.h Fri May 7 03:25:00 2010 (r23039) @@ -0,0 +1,24 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, + int64_t pts, AVRational pixel_aspect);
..this is missing multiple inclusion guards and appropriate header #includes to pass 'make checkheaders'.
it does not need multiple inclusion guards it doesnt really need the includes either but ill add them unless you are quicker. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Opposition brings concord. Out of discord comes the fairest harmony. -- Heraclitus
On Thu, Jun 17, 2010 at 12:06:37PM +0200, Michael Niedermayer wrote:
On Thu, Jun 17, 2010 at 11:32:49AM +0200, Diego Biurrun wrote:
On Fri, May 07, 2010 at 03:25:00AM +0200, michael wrote:
Log: Add "Memory buffer source filter" from SOC. This is needed by the current SOC-ffmpeg.c code.
As usual you ignore certain requirements..
if they can be ignored they hardly could have been required That said this code is from soc and even if you prefer flaming me iam not the author of this file. And of course ive not ignored it but rather i concentrate on getting the code working properly not on things unrelated to code and developers interacting with code (mainntance & readability & so on) aka i forgot about it
That sure is a set of rules I wish would apply to me.
--- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/libavfilter/vsrc_buffer.h Fri May 7 03:25:00 2010 (r23039) @@ -0,0 +1,24 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, + int64_t pts, AVRational pixel_aspect);
..this is missing multiple inclusion guards and appropriate header #includes to pass 'make checkheaders'.
it does not need multiple inclusion guards it doesnt really need the includes either but ill add them unless you are quicker.
You never added them. The file could also use a stdint.h #include. Diego
On Sat, Jul 17, 2010 at 11:36:13AM +0200, Diego Biurrun wrote:
On Thu, Jun 17, 2010 at 12:06:37PM +0200, Michael Niedermayer wrote:
On Thu, Jun 17, 2010 at 11:32:49AM +0200, Diego Biurrun wrote:
On Fri, May 07, 2010 at 03:25:00AM +0200, michael wrote:
Log: Add "Memory buffer source filter" from SOC. This is needed by the current SOC-ffmpeg.c code.
As usual you ignore certain requirements..
if they can be ignored they hardly could have been required That said this code is from soc and even if you prefer flaming me iam not the author of this file. And of course ive not ignored it but rather i concentrate on getting the code working properly not on things unrelated to code and developers interacting with code (mainntance & readability & so on) aka i forgot about it
That sure is a set of rules I wish would apply to me.
i wish that too * you fix issues 7minutes after your first reply * you concentrate on getting code and documentation in perfect functional maintainable, readable and fast state, instead of breaking things to hide warnings.
--- /dev/null 00:00:00 1970 (empty, because file is newly added) +++ trunk/libavfilter/vsrc_buffer.h Fri May 7 03:25:00 2010 (r23039) @@ -0,0 +1,24 @@ + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + */ + +int av_vsrc_buffer_add_frame(AVFilterContext *buffer_filter, AVFrame *frame, + int64_t pts, AVRational pixel_aspect);
..this is missing multiple inclusion guards and appropriate header #includes to pass 'make checkheaders'.
it does not need multiple inclusion guards it doesnt really need the includes either but ill add them unless you are quicker.
You never added them.
r23637, just 7 minutes after my mail
The file could also use a stdint.h #include.
thats unneeded from what i remember stdint.h or inttypes is amongth the ones included by avfilter/avutil/... main header which we include already. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates
Michael Niedermayer <michaelni at gmx.at> writes:
The file could also use a stdint.h #include.
thats unneeded from what i remember stdint.h or inttypes is amongth the ones included by avfilter/avutil/... main header which we include already.
There is no promise this will remain the case. All files should include whatever headers they need directly, even if one happens to be indirectly included by another. -- M?ns Rullg?rd mans at mansr.com
On Sat, Jul 17, 2010 at 08:28:54PM +0100, M?ns Rullg?rd wrote:
Michael Niedermayer <michaelni at gmx.at> writes:
The file could also use a stdint.h #include.
thats unneeded from what i remember stdint.h or inttypes is amongth the ones included by avfilter/avutil/... main header which we include already.
There is no promise this will remain the case.
its certain that inttypes or stdint will be included by the main headers because their types are used by the public api all over the place.
All files should include whatever headers they need directly, even if one happens to be indirectly included by another.
i faintly remember you saying you didnt mind the main headers or common.h being used instead of repeating the standard includes in them in every file. but maybe i misremember or it was someone else ... either way, litterally the rule of "All files should include whatever headers they need directly, even if one happens to be indirectly included by another." Is not implementable unless you provide a automated way to detect such missing includes. Thats besides the wasted time enforcing such rule would lead to and it might also slow compilation down with some compilers. [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB Its not that you shouldnt use gotos but rather that you should write readable code and code with gotos often but not always is less readable
Michael Niedermayer <michaelni at gmx.at> writes:
On Sat, Jul 17, 2010 at 08:28:54PM +0100, M?ns Rullg?rd wrote:
Michael Niedermayer <michaelni at gmx.at> writes:
The file could also use a stdint.h #include.
thats unneeded from what i remember stdint.h or inttypes is amongth the ones included by avfilter/avutil/... main header which we include already.
There is no promise this will remain the case.
its certain that inttypes or stdint will be included by the main headers because their types are used by the public api all over the place.
The API could in theory change, but fair enough.
All files should include whatever headers they need directly, even if one happens to be indirectly included by another.
i faintly remember you saying you didnt mind the main headers or common.h being used instead of repeating the standard includes in them in every file. but maybe i misremember or it was someone else ...
either way, litterally the rule of "All files should include whatever headers they need directly, even if one happens to be indirectly included by another."
Is not implementable unless you provide a automated way to detect such missing includes. Thats besides the wasted time enforcing such rule would lead to and it might also slow compilation down with some compilers.
I'm not suggesting anyone spend great amounts of time hunting for exactly what is needed. However, if for example you use any of the av_str* functions, I think it is reasonable to know these are declared in avstring.h and include that. If something is missed, it's no big deal. The reason I want this guideline is that it reduces the amount of cleanup needed if an include is ever dropped from a header. These things happen, and chasing down every optionally built file that might need updating takes time. -- M?ns Rullg?rd mans at mansr.com
Michael Niedermayer <michaelni at gmx.at> writes:
On Thu, Jun 17, 2010 at 11:32:49AM +0200, Diego Biurrun wrote:
On Fri, May 07, 2010 at 03:25:00AM +0200, michael wrote:
Log: Add "Memory buffer source filter" from SOC. This is needed by the current SOC-ffmpeg.c code.
As usual you ignore certain requirements..
if they can be ignored they hardly could have been required That said this code is from soc and even if you prefer flaming me iam not the author of this file.
You are responsible for what you commit.
And of course ive not ignored it but rather i concentrate on getting the code working properly not on things unrelated to code and developers interacting with code (mainntance & readability & so on) aka i forgot about it
Would you at least grant me and Diego permission to fix trivial issues like these without sending patches or asking about each one? -- M?ns Rullg?rd mans at mansr.com
On Sat, Jul 17, 2010 at 10:48:08AM +0100, M?ns Rullg?rd wrote:
Michael Niedermayer <michaelni at gmx.at> writes:
On Thu, Jun 17, 2010 at 11:32:49AM +0200, Diego Biurrun wrote:
On Fri, May 07, 2010 at 03:25:00AM +0200, michael wrote:
Log: Add "Memory buffer source filter" from SOC. This is needed by the current SOC-ffmpeg.c code.
As usual you ignore certain requirements..
if they can be ignored they hardly could have been required That said this code is from soc and even if you prefer flaming me iam not the author of this file.
You are responsible for what you commit.
iam and i fixed the issue diego pointed at as far as i could guess from Diegos: "As usual you ignore certain requirements.." what he meant.
And of course ive not ignored it but rather i concentrate on getting the code working properly not on things unrelated to code and developers interacting with code (mainntance & readability & so on) aka i forgot about it
Would you at least grant me and Diego permission to fix trivial issues like these without sending patches or asking about each one?
I dont mind if you add missing includes and multiple inclusion guards. about diego i prefer if he sends patches when adding private header includes to random places and such things [...] -- Michael GnuPG fingerprint: 9FF2128B147EF6730BADF133611EC787040B0FAB I am the wisest man alive, for I know one thing, and that is that I know nothing. -- Socrates
participants (4)
-
diego@biurrun.de -
mans@mansr.com -
michaelni@gmx.at -
subversion@mplayerhq.hu