Bug 1152016 - Suppress fprintf(stderr)'s from jpeg in MJPEG decode. r=pkerr, a=sledru
authorRandell Jesup <rjesup@jesup.org>
Tue, 07 Apr 2015 22:55:48 -0400
changeset 260248 97d33db56113
parent 260247 f6448c4cf87f
child 260249 b7d8d79c1ee5
push id727
push userryanvm@gmail.com
push date2015-04-23 14:45 +0000
treeherdermozilla-release@7c66212e4c09 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewerspkerr, sledru
bugs1152016
milestone38.0
Bug 1152016 - Suppress fprintf(stderr)'s from jpeg in MJPEG decode. r=pkerr, a=sledru
media/libyuv/include/libyuv/mjpeg_decoder.h
media/libyuv/source/mjpeg_decoder.cc
--- a/media/libyuv/include/libyuv/mjpeg_decoder.h
+++ b/media/libyuv/include/libyuv/mjpeg_decoder.h
@@ -156,16 +156,17 @@ class LIBYUV_API MJpegDecoder {
   // Methods that are passed to jpeglib.
   static int fill_input_buffer(jpeg_decompress_struct* cinfo);
   static void init_source(jpeg_decompress_struct* cinfo);
   static void skip_input_data(jpeg_decompress_struct* cinfo,
                               long num_bytes);  // NOLINT
   static void term_source(jpeg_decompress_struct* cinfo);
 
   static void ErrorHandler(jpeg_common_struct* cinfo);
+  static void OutputHandler(jpeg_common_struct* cinfo);
 
   void AllocOutputBuffers(int num_outbufs);
   void DestroyOutputBuffers();
 
   LIBYUV_BOOL StartDecode();
   LIBYUV_BOOL FinishDecode();
 
   void SetScanlinePointers(uint8** data);
--- a/media/libyuv/source/mjpeg_decoder.cc
+++ b/media/libyuv/source/mjpeg_decoder.cc
@@ -58,16 +58,19 @@ MJpegDecoder::MJpegDecoder()
       databuf_strides_(NULL) {
   decompress_struct_ = new jpeg_decompress_struct;
   source_mgr_ = new jpeg_source_mgr;
 #ifdef HAVE_SETJMP
   error_mgr_ = new SetJmpErrorMgr;
   decompress_struct_->err = jpeg_std_error(&error_mgr_->base);
   // Override standard exit()-based error handler.
   error_mgr_->base.error_exit = &ErrorHandler;
+#ifndef DEBUG_MJPEG
+  error_mgr_->base.output_message = &OutputHandler;
+#endif
 #endif
   decompress_struct_->client_data = NULL;
   source_mgr_->init_source = &init_source;
   source_mgr_->fill_input_buffer = &fill_input_buffer;
   source_mgr_->skip_input_data = &skip_input_data;
   source_mgr_->resync_to_restart = &jpeg_resync_to_restart;
   source_mgr_->term_source = &term_source;
   jpeg_create_decompress(decompress_struct_);
@@ -438,17 +441,23 @@ void MJpegDecoder::ErrorHandler(j_common
   // ERROR: Error in jpeglib: buf
 #endif
 
   SetJmpErrorMgr* mgr = (SetJmpErrorMgr*)(cinfo->err);
   // This rewinds the call stack to the point of the corresponding setjmp()
   // and causes it to return (for a second time) with value 1.
   longjmp(mgr->setjmp_buffer, 1);
 }
+
+#ifndef DEBUG_MJPEG
+void MJpegDecoder::OutputHandler(j_common_ptr cinfo) {
+  // silently eat messages
+}
 #endif
+#endif // HAVE_SETJMP
 
 void MJpegDecoder::AllocOutputBuffers(int num_outbufs) {
   if (num_outbufs != num_outbufs_) {
     // We could perhaps optimize this case to resize the output buffers without
     // necessarily having to delete and recreate each one, but it's not worth
     // it.
     DestroyOutputBuffers();