You've already forked libopenshot
mirror of
https://github.com/OpenShot/libopenshot.git
synced 2026-03-02 08:53:52 -08:00
Added alpha to all FFmpegReader source images, which is needed by the timeline class. Also, added alpha to the AddColor() method. Now even the background of the timeline can be transparent, along with all layers... even the bottom layer.
This commit is contained in:
@@ -32,7 +32,7 @@ void FFmpegReader::InitScalers()
|
||||
for (int x = 0; x < num_of_rescalers; x++)
|
||||
{
|
||||
SwsContext *img_convert_ctx = sws_getContext(info.width, info.height, pCodecCtx->pix_fmt, info.width,
|
||||
info.height, PIX_FMT_RGB24, SWS_FAST_BILINEAR, NULL, NULL, NULL);
|
||||
info.height, PIX_FMT_RGBA, SWS_FAST_BILINEAR, NULL, NULL, NULL);
|
||||
|
||||
// Add rescaler to vector
|
||||
image_rescalers.push_back(img_convert_ctx);
|
||||
@@ -643,13 +643,13 @@ void FFmpegReader::ProcessVideoPacket(int requested_frame)
|
||||
throw OutOfBoundsFrame("Convert Image Broke!", current_frame, video_length);
|
||||
|
||||
// Determine required buffer size and allocate buffer
|
||||
numBytes = avpicture_get_size(PIX_FMT_RGB24, width, height);
|
||||
numBytes = avpicture_get_size(PIX_FMT_RGBA, width, height);
|
||||
buffer = (uint8_t *) av_malloc(numBytes * sizeof(uint8_t));
|
||||
|
||||
// Assign appropriate parts of buffer to image planes in pFrameRGB
|
||||
// Note that pFrameRGB is an AVFrame, but AVFrame is a superset
|
||||
// of AVPicture
|
||||
avpicture_fill((AVPicture *) pFrameRGB, buffer, PIX_FMT_RGB24, width, height);
|
||||
avpicture_fill((AVPicture *) pFrameRGB, buffer, PIX_FMT_RGBA, width, height);
|
||||
|
||||
// Resize / Convert to RGB
|
||||
sws_scale(img_convert_ctx, my_frame->data, my_frame->linesize, 0,
|
||||
@@ -661,7 +661,7 @@ void FFmpegReader::ProcessVideoPacket(int requested_frame)
|
||||
f = CreateFrame(current_frame);
|
||||
|
||||
// Add Image data to frame
|
||||
f->AddImage(width, height, "RGB", Magick::CharPixel, buffer);
|
||||
f->AddImage(width, height, "RGBA", Magick::CharPixel, buffer);
|
||||
|
||||
#pragma omp critical (openshot_cache)
|
||||
// Update working cache
|
||||
|
||||
@@ -432,7 +432,7 @@ void Frame::AddColor(int width, int height, string color)
|
||||
image = tr1::shared_ptr<Magick::Image>(new Magick::Image(Magick::Geometry(width, height), Magick::Color(color)));
|
||||
|
||||
// Give image a transparent background color
|
||||
image->backgroundColor(Magick::Color("none"));
|
||||
image->backgroundColor(Magick::Color("#000000ff"));
|
||||
|
||||
// Update height and width
|
||||
width = image->columns();
|
||||
|
||||
@@ -352,7 +352,7 @@ void Keyframe::PrintValues() {
|
||||
|
||||
for (vector<Coordinate>::iterator it = Values.begin() + 1; it != Values.end(); it++) {
|
||||
Coordinate c = *it;
|
||||
cout << int(round(c.X)) << "\t" << int(round(c.Y)) << "\t" << c.increasing << "\t" << c.repeated.num << "\t" << c.repeated.den << "\t" << c.delta << endl;
|
||||
cout << int(round(c.X)) << "\t" << c.Y << "\t" << c.increasing << "\t" << c.repeated.num << "\t" << c.repeated.den << "\t" << c.delta << endl;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -33,6 +33,10 @@ int main()
|
||||
c1.gravity = GRAVITY_LEFT;
|
||||
c1.scale = SCALE_CROP;
|
||||
c1.Layer(0);
|
||||
c1.End(16.0);
|
||||
c1.alpha.AddPoint(1, 0.0);
|
||||
c1.alpha.AddPoint(360, 0.0, LINEAR);
|
||||
c1.alpha.AddPoint(384, 1.0);
|
||||
|
||||
// CLIP 2 (wave form)
|
||||
c2.Position(0.0);
|
||||
@@ -77,7 +81,7 @@ int main()
|
||||
// Output stream info
|
||||
w.OutputStreamInfo();
|
||||
|
||||
for (int frame = 1; frame <= 300; frame++)
|
||||
for (int frame = 1; frame <= 600; frame++)
|
||||
{
|
||||
tr1::shared_ptr<Frame> f = t.GetFrame(frame);
|
||||
if (f)
|
||||
|
||||
@@ -69,7 +69,7 @@ void Timeline::add_layer(tr1::shared_ptr<Frame> new_frame, Clip* source_clip, in
|
||||
int red = color.red.GetInt(timeline_frame_number);
|
||||
int green = color.green.GetInt(timeline_frame_number);
|
||||
int blue = color.blue.GetInt(timeline_frame_number);
|
||||
new_frame->AddColor(width, height, Magick::Color(red, green, blue));
|
||||
new_frame->AddColor(width, height, Magick::Color(red, green, blue, 0));
|
||||
}
|
||||
|
||||
/* COPY AUDIO - with correct volume */
|
||||
@@ -214,7 +214,7 @@ void Timeline::add_layer(tr1::shared_ptr<Frame> new_frame, Clip* source_clip, in
|
||||
cout << "COMPLEX" << endl;
|
||||
// Use the distort operator, which is very CPU intensive
|
||||
// origin X,Y Scale Angle NewX,NewY
|
||||
double distort_args[7] = {0,0, sx,sy, r, x-1,y-1 };
|
||||
double distort_args[7] = {0,0, sx,sy, r, x,y };
|
||||
source_image->distort(Magick::ScaleRotateTranslateDistortion, 7, distort_args, false);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user