Commit 1ff93ffc authored by Todd Kirby's avatar Todd Kirby Committed by Michael Niedermayer

padding support in ffmpeg patch by (Todd Kirby <doubleshot at pacbell dot net>)

Originally committed as revision 2982 to svn://svn.ffmpeg.org/ffmpeg/trunk
parent 929a0c41
......@@ -234,6 +234,18 @@ set bottom crop band size (in pixels)
set left crop band size (in pixels)
@item -cropright size
set right crop band size (in pixels)
@item -padtop size
set top pad band size (in pixels)
@item -padbottom size
set bottom pad band size (in pixels)
@item -padleft size
set left pad band size (in pixels)
@item -padright size
set right pad band size (in pixels)
@item -padcolor color
set right pad band size (hex). The value for pad color is expressed
as a six digit hexidecimal number where the first two digits represent red,
middle two digits green and last two digits blue. Defaults to 000000 (black)
@item -vn
disable video recording
@item -bt tolerance
......
This diff is collapsed.
......@@ -17,7 +17,7 @@ extern "C" {
#define FFMPEG_VERSION_INT 0x000408
#define FFMPEG_VERSION "0.4.8"
#define LIBAVCODEC_BUILD 4707
#define LIBAVCODEC_BUILD 4708
#define LIBAVCODEC_VERSION_INT FFMPEG_VERSION_INT
#define LIBAVCODEC_VERSION FFMPEG_VERSION
......@@ -1821,7 +1821,10 @@ ImgReSampleContext *img_resample_init(int output_width, int output_height,
ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
int iwidth, int iheight,
int topBand, int bottomBand,
int leftBand, int rightBand);
int leftBand, int rightBand,
int padtop, int padbottom,
int padleft, int padright);
void img_resample(ImgReSampleContext *s,
AVPicture *output, const AVPicture *input);
......
......@@ -45,7 +45,10 @@
#define LINE_BUF_HEIGHT (NB_TAPS * 4)
struct ImgReSampleContext {
int iwidth, iheight, owidth, oheight, topBand, bottomBand, leftBand, rightBand;
int iwidth, iheight, owidth, oheight;
int topBand, bottomBand, leftBand, rightBand;
int padtop, padbottom, padleft, padright;
int pad_owidth, pad_oheight;
int h_incr, v_incr;
int16_t h_filters[NB_PHASES][NB_TAPS] __align8; /* horizontal filters */
int16_t v_filters[NB_PHASES][NB_TAPS] __align8; /* vertical filters */
......@@ -532,6 +535,7 @@ static void component_resample(ImgReSampleContext *s,
&s->v_filters[phase_y][0]);
src_y += s->v_incr;
output += owrap;
}
}
......@@ -572,13 +576,16 @@ static void build_filter(int16_t *filter, float factor)
ImgReSampleContext *img_resample_init(int owidth, int oheight,
int iwidth, int iheight)
{
return img_resample_full_init(owidth, oheight, iwidth, iheight, 0, 0, 0, 0);
return img_resample_full_init(owidth, oheight, iwidth, iheight,
0, 0, 0, 0, 0, 0, 0, 0);
}
ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
int iwidth, int iheight,
int topBand, int bottomBand,
int leftBand, int rightBand)
int leftBand, int rightBand,
int padtop, int padbottom,
int padleft, int padright)
{
ImgReSampleContext *s;
......@@ -593,19 +600,30 @@ ImgReSampleContext *img_resample_full_init(int owidth, int oheight,
s->oheight = oheight;
s->iwidth = iwidth;
s->iheight = iheight;
s->topBand = topBand;
s->bottomBand = bottomBand;
s->leftBand = leftBand;
s->rightBand = rightBand;
s->h_incr = ((iwidth - leftBand - rightBand) * POS_FRAC) / owidth;
s->v_incr = ((iheight - topBand - bottomBand) * POS_FRAC) / oheight;
build_filter(&s->h_filters[0][0], (float) owidth / (float) (iwidth - leftBand - rightBand));
build_filter(&s->v_filters[0][0], (float) oheight / (float) (iheight - topBand - bottomBand));
s->padtop = padtop;
s->padbottom = padbottom;
s->padleft = padleft;
s->padright = padright;
s->pad_owidth = owidth - (padleft + padright);
s->pad_oheight = oheight - (padtop + padbottom);
s->h_incr = ((iwidth - leftBand - rightBand) * POS_FRAC) / s->pad_owidth;
s->v_incr = ((iheight - topBand - bottomBand) * POS_FRAC) / s->pad_oheight;
build_filter(&s->h_filters[0][0], (float) s->pad_owidth /
(float) (iwidth - leftBand - rightBand));
build_filter(&s->v_filters[0][0], (float) s->pad_oheight /
(float) (iheight - topBand - bottomBand));
return s;
fail:
fail:
av_free(s);
return NULL;
}
......@@ -614,13 +632,20 @@ void img_resample(ImgReSampleContext *s,
AVPicture *output, const AVPicture *input)
{
int i, shift;
uint8_t* optr;
for(i=0;i<3;i++) {
for (i=0;i<3;i++) {
shift = (i == 0) ? 0 : 1;
component_resample(s, output->data[i], output->linesize[i],
s->owidth >> shift, s->oheight >> shift,
input->data[i] + (input->linesize[i] * (s->topBand >> shift)) + (s->leftBand >> shift),
input->linesize[i], ((s->iwidth - s->leftBand - s->rightBand) >> shift),
optr = output->data[i] + (((output->linesize[i] *
s->padtop) + s->padleft) >> shift);
component_resample(s, optr, output->linesize[i],
s->pad_owidth >> shift, s->pad_oheight >> shift,
input->data[i] + (input->linesize[i] *
(s->topBand >> shift)) + (s->leftBand >> shift),
input->linesize[i], ((s->iwidth - s->leftBand -
s->rightBand) >> shift),
(s->iheight - s->topBand - s->bottomBand) >> shift);
}
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment