mirror of
https://github.com/webmproject/libwebp.git
synced 2024-12-26 05:38:22 +01:00
WebPReportProgress: use non-encoder specific params
Take picture and percent value storage location instead of VP8Encoder. This will allow reuse by the lossless encoder. Change-Id: Ic49dbc800cc3e2df60d20f4ebac277f68ed6031b
This commit is contained in:
parent
880fd98ca1
commit
f18281ffa0
@ -311,7 +311,7 @@ int VP8EncFinishAlpha(VP8Encoder* enc) {
|
||||
enc->alpha_data_size_ = (uint32_t)tmp_size;
|
||||
enc->alpha_data_ = tmp_data;
|
||||
}
|
||||
return WebPReportProgress(enc, enc->percent_ + 20);
|
||||
return WebPReportProgress(enc->pic_, enc->percent_ + 20, &enc->percent_);
|
||||
}
|
||||
|
||||
void VP8EncDeleteAlpha(VP8Encoder* enc) {
|
||||
|
@ -929,7 +929,7 @@ int VP8StatLoop(VP8Encoder* const enc) {
|
||||
}
|
||||
}
|
||||
}
|
||||
return WebPReportProgress(enc, final_percent);
|
||||
return WebPReportProgress(enc->pic_, final_percent, &enc->percent_);
|
||||
}
|
||||
|
||||
//------------------------------------------------------------------------------
|
||||
|
@ -70,9 +70,10 @@ void VP8IteratorInit(VP8Encoder* const enc, VP8EncIterator* const it) {
|
||||
}
|
||||
|
||||
int VP8IteratorProgress(const VP8EncIterator* const it, int delta) {
|
||||
if (delta && it->enc_->pic_->progress_hook) {
|
||||
const int percent = it->percent0_ + delta * it->y_ / (it->enc_->mb_h_ - 1);
|
||||
return WebPReportProgress(it->enc_, percent);
|
||||
VP8Encoder* const enc = it->enc_;
|
||||
if (delta && enc->pic_->progress_hook) {
|
||||
const int percent = it->percent0_ + delta * it->y_ / (enc->mb_h_ - 1);
|
||||
return WebPReportProgress(enc->pic_, percent, &enc->percent_);
|
||||
}
|
||||
return 1;
|
||||
}
|
||||
|
@ -416,7 +416,8 @@ int VP8EncWrite(VP8Encoder* const enc) {
|
||||
if (size)
|
||||
ok = ok && pic->writer(buf, size, pic);
|
||||
VP8BitWriterWipeOut(enc->parts_ + p); // will free the internal buffer.
|
||||
ok = ok && WebPReportProgress(enc, enc->percent_ + percent_per_part);
|
||||
ok = ok && WebPReportProgress(pic, enc->percent_ + percent_per_part,
|
||||
&enc->percent_);
|
||||
}
|
||||
|
||||
// Padding byte
|
||||
@ -425,7 +426,7 @@ int VP8EncWrite(VP8Encoder* const enc) {
|
||||
}
|
||||
|
||||
enc->coded_size_ = (int)(CHUNK_HEADER_SIZE + riff_size);
|
||||
ok = ok && WebPReportProgress(enc, final_percent);
|
||||
ok = ok && WebPReportProgress(pic, final_percent, &enc->percent_);
|
||||
return ok;
|
||||
}
|
||||
|
||||
|
@ -474,7 +474,8 @@ int VP8StatLoop(VP8Encoder* const enc);
|
||||
// in webpenc.c
|
||||
// Assign an error code to a picture. Return false for convenience.
|
||||
int WebPEncodingSetError(const WebPPicture* const pic, WebPEncodingError error);
|
||||
int WebPReportProgress(VP8Encoder* const enc, int percent);
|
||||
int WebPReportProgress(const WebPPicture* const pic,
|
||||
int percent, int* const percent_store);
|
||||
|
||||
// in analysis.c
|
||||
// Main analysis loop. Decides the segmentations and complexity.
|
||||
|
@ -303,7 +303,7 @@ static void StoreStats(VP8Encoder* const enc) {
|
||||
stats->block_count[i] = enc->block_count_[i];
|
||||
}
|
||||
}
|
||||
WebPReportProgress(enc, 100); // done!
|
||||
WebPReportProgress(enc->pic_, 100, &enc->percent_); // done!
|
||||
}
|
||||
|
||||
int WebPEncodingSetError(const WebPPicture* const pic,
|
||||
@ -314,10 +314,10 @@ int WebPEncodingSetError(const WebPPicture* const pic,
|
||||
return 0;
|
||||
}
|
||||
|
||||
int WebPReportProgress(VP8Encoder* const enc, int percent) {
|
||||
if (percent != enc->percent_) {
|
||||
WebPPicture* const pic = enc->pic_;
|
||||
enc->percent_ = percent;
|
||||
int WebPReportProgress(const WebPPicture* const pic,
|
||||
int percent, int* const percent_store) {
|
||||
if (percent_store != NULL && percent != *percent_store) {
|
||||
*percent_store = percent;
|
||||
if (pic->progress_hook && !pic->progress_hook(percent, pic)) {
|
||||
// user abort requested
|
||||
WebPEncodingSetError(pic, VP8_ENC_ERROR_USER_ABORT);
|
||||
|
Loading…
Reference in New Issue
Block a user