aboutsummaryrefslogtreecommitdiffstats
path: root/vhook/watermark.c
diff options
context:
space:
mode:
authorDiego Biurrun <diego@biurrun.de>2005-12-17 18:14:38 +0000
committerDiego Biurrun <diego@biurrun.de>2005-12-17 18:14:38 +0000
commit115329f16062074e11ccf3b89ead6176606c9696 (patch)
treee98aa993905a702688bf821737ab9a443969fc28 /vhook/watermark.c
parentd76319b1ab716320f6e6a4d690b85fe4504ebd5b (diff)
downloadffmpeg-115329f16062074e11ccf3b89ead6176606c9696.tar.gz
COSMETICS: Remove all trailing whitespace.
Originally committed as revision 4749 to svn://svn.ffmpeg.org/ffmpeg/trunk
Diffstat (limited to 'vhook/watermark.c')
-rw-r--r--vhook/watermark.c156
1 files changed, 78 insertions, 78 deletions
diff --git a/vhook/watermark.c b/vhook/watermark.c
index 99f7407899..66a601312f 100644
--- a/vhook/watermark.c
+++ b/vhook/watermark.c
@@ -1,5 +1,5 @@
/*
- * Watermark Hook
+ * Watermark Hook
* Copyright (c) 2005 Marcus Engene myfirstname(at)mylastname.se
*
* The watermarkpicture works like this. (Assuming colorintencities 0..0xff)
@@ -11,7 +11,7 @@
* > 0xff, result = 0xff
*
* This way a mask that is visible both in light pictures and in dark can be
- * made (fex by using a picture generated by gimp and the bump map tool).
+ * made (fex by using a picture generated by gimp and the bump map tool).
*
* An example watermark file is at
* http://engene.se/ffmpeg_watermark.gif
@@ -41,7 +41,7 @@
//#include <fcntl.h>
#include <unistd.h>
#include <stdarg.h>
-
+
#include "common.h"
#include "avformat.h"
@@ -57,8 +57,8 @@ typedef struct {
const char *p_ext;
int videoStream;
int frameFinished;
- AVCodecContext *pCodecCtx;
- AVCodec *pCodec;
+ AVCodecContext *pCodecCtx;
+ AVCodec *pCodec;
AVFrame *pFrame;
AVPacket packet;
int numBytes;
@@ -66,7 +66,7 @@ typedef struct {
int i;
AVInputFormat *file_iformat;
AVStream *st;
- int is_done;
+ int is_done;
AVFrame *pFrameRGB;
} ContextInfo;
@@ -74,7 +74,7 @@ int get_watermark_picture(ContextInfo *ci, int cleanup);
/****************************************************************************
- *
+ *
****************************************************************************/
void Release(void *ctx)
{
@@ -82,14 +82,14 @@ void Release(void *ctx)
ci = (ContextInfo *) ctx;
if (ci) get_watermark_picture(ci, 1);
-
+
if (ctx)
av_free(ctx);
}
/****************************************************************************
- *
+ *
****************************************************************************/
int Configure(void **ctxp, int argc, char *argv[])
{
@@ -100,9 +100,9 @@ int Configure(void **ctxp, int argc, char *argv[])
ci = (ContextInfo *) *ctxp;
optind = 1;
-
+
// Struct is mallocz:ed so no need to reset.
-
+
while ((c = getopt(argc, argv, "f:")) > 0) {
switch (c) {
case 'f':
@@ -114,13 +114,13 @@ int Configure(void **ctxp, int argc, char *argv[])
return -1;
}
}
-
+
//
if (0 == ci->filename[0]) {
av_log(NULL, AV_LOG_ERROR, "Watermark: There is no filename specified.\n");
return -1;
}
-
+
av_register_all();
return get_watermark_picture(ci, 0);
}
@@ -129,18 +129,18 @@ int Configure(void **ctxp, int argc, char *argv[])
/****************************************************************************
* Why is this a void returning functions? I want to be able to go wrong!
****************************************************************************/
-void Process(void *ctx,
- AVPicture *picture,
- enum PixelFormat pix_fmt,
- int src_width,
- int src_height,
+void Process(void *ctx,
+ AVPicture *picture,
+ enum PixelFormat pix_fmt,
+ int src_width,
+ int src_height,
int64_t pts)
{
ContextInfo *ci = (ContextInfo *) ctx;
char *buf = 0;
AVPicture picture1;
AVPicture *pict = picture;
-
+
AVFrame *pFrameRGB;
int xm_size;
int ym_size;
@@ -154,9 +154,9 @@ void Process(void *ctx,
uint32_t pixel_meck;
uint32_t pixel;
uint32_t pixelm;
- int tmp;
-
-
+ int tmp;
+
+
//?? (void) ci;
if (pix_fmt != PIX_FMT_RGBA32) {
@@ -166,7 +166,7 @@ void Process(void *ctx,
buf = av_malloc(size);
avpicture_fill(&picture1, buf, PIX_FMT_RGBA32, src_width, src_height);
- if (img_convert(&picture1, PIX_FMT_RGBA32,
+ if (img_convert(&picture1, PIX_FMT_RGBA32,
picture, pix_fmt, src_width, src_height) < 0) {
av_free(buf);
return;
@@ -176,15 +176,15 @@ void Process(void *ctx,
/* Insert filter code here */ /* ok */
- // Get me next frame
+ // Get me next frame
if (0 > get_watermark_picture(ci, 0)) {
return;
- }
+ }
// These are the three original static variables in the ffmpeg hack.
pFrameRGB = ci->pFrameRGB;
xm_size = ci->x_size;
ym_size = ci->y_size;
-
+
// I'll do the *4 => <<2 crap later. Most compilers understand that anyway.
// According to avcodec.h PIX_FMT_RGBA32 is handled in endian specific manner.
for (y=0; y<src_height; y++) {
@@ -214,23 +214,23 @@ void Process(void *ctx,
if (tmp > 255) tmp = 255;
if (tmp < 0) tmp = 0;
pixel_meck |= (tmp << 0) & 0xff;
-
-
+
+
// test:
//pixel_meck = pixel & 0xff000000;
//pixel_meck |= (pixelm & 0x00ffffff);
*p_pixel = pixel_meck;
- offs += 4;
+ offs += 4;
} // foreach X
- } // foreach Y
-
-
-
+ } // foreach Y
+
+
+
if (pix_fmt != PIX_FMT_RGBA32) {
- if (img_convert(picture, pix_fmt,
+ if (img_convert(picture, pix_fmt,
&picture1, PIX_FMT_RGBA32, src_width, src_height) < 0) {
}
}
@@ -243,7 +243,7 @@ void Process(void *ctx,
* When cleanup == 0, we try to get the next frame. If no next frame, nothing
* is done.
*
- * This code follows the example on
+ * This code follows the example on
* http://www.inb.uni-luebeck.de/~boehme/using_libavcodec.html
*
* 0 = ok, -1 = error
@@ -254,11 +254,11 @@ int get_watermark_picture(ContextInfo *ci, int cleanup)
// Yes, *pFrameRGB arguments must be null the first time otherwise it's not good..
// This block is only executed the first time we enter this function.
- if (0 == ci->pFrameRGB &&
- 0 == cleanup)
+ if (0 == ci->pFrameRGB &&
+ 0 == cleanup)
{
-
- /*
+
+ /*
* The last three parameters specify the file format, buffer size and format
* parameters; by simply specifying NULL or 0 we ask libavformat to auto-detect
* the format and use a default buffer size. (Didn't work!)
@@ -285,24 +285,24 @@ int get_watermark_picture(ContextInfo *ci, int cleanup)
av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Really failed to find iformat [%s]\n", ci->p_ext);
return -1;
}
- // now continues the Martin template.
-
+ // now continues the Martin template.
+
if (av_open_input_file(&ci->pFormatCtx, ci->filename, ci->file_iformat, 0, NULL)!=0) {
av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to open input file [%s]\n", ci->filename);
return -1;
- }
+ }
}
-
- /*
+
+ /*
* This fills the streams field of the AVFormatContext with valid information.
*/
if(av_find_stream_info(ci->pFormatCtx)<0) {
av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to find stream info\n");
return -1;
}
-
+
/*
- * As mentioned in the introduction, we'll handle only video streams, not audio
+ * As mentioned in the introduction, we'll handle only video streams, not audio
* streams. To make things nice and easy, we simply use the first video stream we
* find.
*/
@@ -317,48 +317,48 @@ int get_watermark_picture(ContextInfo *ci, int cleanup)
av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to find any video stream\n");
return -1;
}
-
+
ci->st = ci->pFormatCtx->streams[ci->videoStream];
ci->x_size = ci->st->codec->width;
ci->y_size = ci->st->codec->height;
-
+
// Get a pointer to the codec context for the video stream
ci->pCodecCtx = ci->pFormatCtx->streams[ci->videoStream]->codec;
-
-
+
+
/*
* OK, so now we've got a pointer to the so-called codec context for our video
* stream, but we still have to find the actual codec and open it.
- */
+ */
// Find the decoder for the video stream
ci->pCodec = avcodec_find_decoder(ci->pCodecCtx->codec_id);
if(ci->pCodec == NULL) {
av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to find any codec\n");
return -1;
}
-
+
// Inform the codec that we can handle truncated bitstreams -- i.e.,
// bitstreams where frame boundaries can fall in the middle of packets
if (ci->pCodec->capabilities & CODEC_CAP_TRUNCATED)
ci->pCodecCtx->flags|=CODEC_FLAG_TRUNCATED;
-
+
// Open codec
if(avcodec_open(ci->pCodecCtx, ci->pCodec)<0) {
av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to open codec\n");
return -1;
}
-
- // Hack to correct wrong frame rates that seem to be generated by some
+
+ // Hack to correct wrong frame rates that seem to be generated by some
// codecs
if (ci->pCodecCtx->time_base.den>1000 && ci->pCodecCtx->time_base.num==1)
- ci->pCodecCtx->time_base.num=1000;
-
+ ci->pCodecCtx->time_base.num=1000;
+
/*
* Allocate a video frame to store the decoded images in.
*/
ci->pFrame = avcodec_alloc_frame();
-
-
+
+
/*
* The RGB image pFrameRGB (of type AVFrame *) is allocated like this:
*/
@@ -368,19 +368,19 @@ int get_watermark_picture(ContextInfo *ci, int cleanup)
av_log(NULL, AV_LOG_ERROR, "get_watermark_picture() Failed to alloc pFrameRGB\n");
return -1;
}
-
+
// Determine required buffer size and allocate buffer
ci->numBytes = avpicture_get_size(PIX_FMT_RGBA32, ci->pCodecCtx->width,
ci->pCodecCtx->height);
ci->buffer = av_malloc(ci->numBytes);
-
+
// Assign appropriate parts of buffer to image planes in pFrameRGB
avpicture_fill((AVPicture *)ci->pFrameRGB, ci->buffer, PIX_FMT_RGBA32,
- ci->pCodecCtx->width, ci->pCodecCtx->height);
+ ci->pCodecCtx->width, ci->pCodecCtx->height);
}
// TODO loop, pingpong etc?
- if (0 == cleanup)
- {
+ if (0 == cleanup)
+ {
// av_log(NULL, AV_LOG_DEBUG, "get_watermark_picture() Get a frame\n");
while(av_read_frame(ci->pFormatCtx, &ci->packet)>=0)
{
@@ -388,32 +388,32 @@ int get_watermark_picture(ContextInfo *ci, int cleanup)
if(ci->packet.stream_index == ci->videoStream)
{
// Decode video frame
- avcodec_decode_video(ci->pCodecCtx, ci->pFrame, &ci->frameFinished,
+ avcodec_decode_video(ci->pCodecCtx, ci->pFrame, &ci->frameFinished,
ci->packet.data, ci->packet.size);
-
+
// Did we get a video frame?
if(ci->frameFinished)
{
// Convert the image from its native format to RGBA32
- img_convert((AVPicture *)ci->pFrameRGB, PIX_FMT_RGBA32,
- (AVPicture*)(ci->pFrame), ci->pCodecCtx->pix_fmt, ci->pCodecCtx->width,
+ img_convert((AVPicture *)ci->pFrameRGB, PIX_FMT_RGBA32,
+ (AVPicture*)(ci->pFrame), ci->pCodecCtx->pix_fmt, ci->pCodecCtx->width,
ci->pCodecCtx->height);
-
+
// Process the video frame (save to disk etc.)
//fprintf(stderr,"banan() New frame!\n");
//DoSomethingWithTheImage(ci->pFrameRGB);
return 0;
}
}
-
+
// Free the packet that was allocated by av_read_frame
av_free_packet(&ci->packet);
}
- ci->is_done = 1;
+ ci->is_done = 1;
return 0;
} // if 0 != cleanup
-
- if (0 != cleanup)
+
+ if (0 != cleanup)
{
// Free the RGB image
if (0 != ci->buffer) {
@@ -423,20 +423,20 @@ int get_watermark_picture(ContextInfo *ci, int cleanup)
if (0 != ci->pFrameRGB) {
av_free(ci->pFrameRGB);
ci->pFrameRGB = 0;
- }
-
+ }
+
// Close the codec
if (0 != ci->pCodecCtx) {
avcodec_close(ci->pCodecCtx);
ci->pCodecCtx = 0;
}
-
+
// Close the video file
if (0 != ci->pFormatCtx) {
- av_close_input_file(ci->pFormatCtx);
+ av_close_input_file(ci->pFormatCtx);
ci->pFormatCtx = 0;
}
-
+
ci->is_done = 0;
}
return 0;