c2a9a9716e
Takes SkYUVAPixmaps. Still implemented in terms of SkYUVAIndex[4] internally. Replace all internal use cases except wacky_yuv_formats. Takes GrRecordingContext rather than GrContext. SkVideoDecoder updated to take GrRecordingContext. Bug: skia:10632 Change-Id: I6e9b9b6a4f11333bce6f87c1ebff0acb297f6540 Reviewed-on: https://skia-review.googlesource.com/c/skia/+/316837 Commit-Queue: Brian Salomon <bsalomon@google.com> Reviewed-by: Adlai Holler <adlai@google.com> Reviewed-by: Robert Phillips <robertphillips@google.com>
67 lines
1.5 KiB
C++
67 lines
1.5 KiB
C++
/*
|
|
* Copyright 2019 Google Inc.
|
|
*
|
|
* Use of this source code is governed by a BSD-style license that can be
|
|
* found in the LICENSE file.
|
|
*/
|
|
|
|
#include "experimental/ffmpeg/SkVideoDecoder.h"
|
|
#include "gm/gm.h"
|
|
#include "include/core/SkCanvas.h"
|
|
#include "include/core/SkStream.h"
|
|
|
|
class VideoDecoderGM : public skiagm::GM {
|
|
SkVideoDecoder fDecoder;
|
|
|
|
public:
|
|
VideoDecoderGM() {}
|
|
|
|
protected:
|
|
|
|
SkString onShortName() override {
|
|
return SkString("videodecoder");
|
|
}
|
|
|
|
SkISize onISize() override {
|
|
return SkISize::Make(1024, 768);
|
|
}
|
|
|
|
void onOnceBeforeDraw() override {
|
|
if (!fDecoder.loadStream(SkStream::MakeFromFile("/skia/ice.mp4"))) {
|
|
SkDebugf("could not load movie file\n");
|
|
}
|
|
SkDebugf("duration %g\n", fDecoder.duration());
|
|
}
|
|
|
|
void onDraw(SkCanvas* canvas) override {
|
|
GrContext* rContext = canvas->recordingContext();
|
|
if (!rContext) {
|
|
return;
|
|
}
|
|
|
|
fDecoder.setGrContext(rContext); // context can change over time in viewer
|
|
|
|
double timeStamp;
|
|
auto img = fDecoder.nextImage(&timeStamp);
|
|
if (!img) {
|
|
(void)fDecoder.rewind();
|
|
img = fDecoder.nextImage(&timeStamp);
|
|
}
|
|
if (img) {
|
|
if (0) {
|
|
SkDebugf("ts %g\n", timeStamp);
|
|
}
|
|
canvas->drawImage(img, 10, 10, nullptr);
|
|
}
|
|
}
|
|
|
|
bool onAnimate(double nanos) override {
|
|
return true;
|
|
}
|
|
|
|
private:
|
|
using INHERITED = GM;
|
|
};
|
|
DEF_GM( return new VideoDecoderGM; )
|
|
|