[FFmpeg-cvslog] Tag n3.1.7 : FFmpeg 3.1.7 release

2017-02-09 Thread git
[ffmpeg] [branch: refs/tags/n3.1.7]
Tag:80f47f4c1740ec1d6cd39840f1121ef10707dfdd
> http://git.videolan.org/gitweb.cgi/ffmpeg.git?a=tag;h=80f47f4c1740ec1d6cd39840f1121ef10707dfdd

Tagger: Michael Niedermayer 
Date:   Thu Feb  9 15:11:59 2017 +0100

FFmpeg 3.1.7 release
___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] [ffmpeg-web] branch master updated. 9bec093 web/download: add FFmpeg 3.1.7 release

2017-02-09 Thread ffmpeg-git
The branch, master has been updated
   via  9bec093e7b3f961f69ba792aff9683281e1225ee (commit)
  from  a90f1e0b4aadb733c54d4971a2ce958df56757ff (commit)


- Log -
commit 9bec093e7b3f961f69ba792aff9683281e1225ee
Author: Michael Niedermayer 
AuthorDate: Thu Feb 9 15:14:19 2017 +0100
Commit: Michael Niedermayer 
CommitDate: Thu Feb 9 15:14:19 2017 +0100

web/download: add FFmpeg 3.1.7 release

diff --git a/src/download b/src/download
index ab8140f..75af039 100644
--- a/src/download
+++ b/src/download
@@ -307,10 +307,10 @@ libpostproc54.  1.100
  

 
-  FFmpeg 3.1.6 "Laplace"
+  FFmpeg 3.1.7 "Laplace"
 
   
-3.1.6 was released on 2016-12-05. It is the latest stable FFmpeg release
+3.1.7 was released on 2017-02-09. It is the latest stable FFmpeg release
 from the 3.1 release branch, which was cut from master on 2016-06-26.
   
   It includes the following library versions:
@@ -328,19 +328,19 @@ libpostproc54.  0.100
 
   
 
-  Download 
xz tarball
-  PGP 
signature
+  Download 
xz tarball
+  PGP 
signature
  
 
-  Download 
bzip2 tarball
-  PGP 
signature
+  Download 
bzip2 tarball
+  PGP 
signature
  
 
-  Download 
gzip tarball
-  PGP 
signature
+  Download 
gzip tarball
+  PGP 
signature
  
 
-  https://git.ffmpeg.org/gitweb/ffmpeg.git/shortlog/n3.1.6";>Changelog
+  https://git.ffmpeg.org/gitweb/ffmpeg.git/shortlog/n3.1.7";>Changelog
   https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/refs/heads/release/3.1:/RELEASE_NOTES";>Release
 Notes
  


---

Summary of changes:
 src/download | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)


hooks/post-receive
-- 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] Tag n2.8.11 : FFmpeg 2.8.11 release

2017-02-09 Thread git
[ffmpeg] [branch: refs/tags/n2.8.11]
Tag:623e339a2b64267360ad033e1e096dee2167b883
> http://git.videolan.org/gitweb.cgi/ffmpeg.git?a=tag;h=623e339a2b64267360ad033e1e096dee2167b883

Tagger: Michael Niedermayer 
Date:   Thu Feb  9 17:13:32 2017 +0100

FFmpeg 2.8.11 release
___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] [ffmpeg-web] branch master updated. 43fd5de web/download: add FFmpeg 2.8.11

2017-02-09 Thread ffmpeg-git
The branch, master has been updated
   via  43fd5deb20bd8bbd945dc600951773d22e359d5b (commit)
  from  9bec093e7b3f961f69ba792aff9683281e1225ee (commit)


- Log -
commit 43fd5deb20bd8bbd945dc600951773d22e359d5b
Author: Michael Niedermayer 
AuthorDate: Thu Feb 9 17:46:45 2017 +0100
Commit: Michael Niedermayer 
CommitDate: Thu Feb 9 17:46:45 2017 +0100

web/download: add FFmpeg 2.8.11

Signed-off-by: Michael Niedermayer 

diff --git a/src/download b/src/download
index 75af039..c9fc6d4 100644
--- a/src/download
+++ b/src/download
@@ -385,10 +385,10 @@ libpostproc54.  0.100

 
 
-  FFmpeg 2.8.10 "Feynman"
+  FFmpeg 2.8.11 "Feynman"
 
   
-2.8.10 was released on 2016-12-06. It is the latest stable FFmpeg release
+2.8.11 was released on 2017-02-09. It is the latest stable FFmpeg release
 from the 2.8 release branch, which was cut from master on 2015-09-05.
 Amongst lots of other changes, it includes all changes from
 ffmpeg-mt, libav master of 2015-08-28, libav 11 as of 2015-08-28.
@@ -408,19 +408,19 @@ libpostproc53.  3.100
 
   
 
-  Download 
xz tarball
-  PGP 
signature
+  Download 
xz tarball
+  PGP 
signature
  
 
-  Download bzip2 tarball
-  PGP 
signature
+  Download bzip2 tarball
+  PGP 
signature
  
 
-  Download 
gzip tarball
-  PGP 
signature
+  Download 
gzip tarball
+  PGP 
signature
  
 
-  https://git.ffmpeg.org/gitweb/ffmpeg.git/shortlog/n2.8.10";>Changelog
+  https://git.ffmpeg.org/gitweb/ffmpeg.git/shortlog/n2.8.11";>Changelog
   https://git.ffmpeg.org/gitweb/ffmpeg.git/blob/refs/heads/release/2.8:/RELEASE_NOTES";>Release
 Notes
  


---

Summary of changes:
 src/download | 18 +-
 1 file changed, 9 insertions(+), 9 deletions(-)


hooks/post-receive
-- 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/tests/mjpegenc_huffman: Remove static in main() table

2017-02-09 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Feb  9 22:56:19 2017 +0100| [d23af72a0cb86298ff740e07b2b293a07c62ed44] | 
committer: Michael Niedermayer

avcodec/tests/mjpegenc_huffman: Remove static in main() table

Avoids false positives when greping for non constant statics

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=d23af72a0cb86298ff740e07b2b293a07c62ed44
---

 libavcodec/tests/mjpegenc_huffman.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavcodec/tests/mjpegenc_huffman.c 
b/libavcodec/tests/mjpegenc_huffman.c
index 33e1f5f..2ed92d0 100644
--- a/libavcodec/tests/mjpegenc_huffman.c
+++ b/libavcodec/tests/mjpegenc_huffman.c
@@ -117,7 +117,7 @@ int main(int argc, char **argv)
 {
 int i, ret = 0;
 // Probabilities of symbols 0..4
-static PTable val_counts[] = {
+PTable val_counts[] = {
 {.value = 0, .prob = 1},
 {.value = 1, .prob = 2},
 {.value = 2, .prob = 5},

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/mjpegenc: Remove non functional huffman reallocation and error handling

2017-02-09 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Feb  9 21:11:51 2017 +0100| [e10bd12c250afb89046c4b0ee3f30d6d23eb8127] | 
committer: Michael Niedermayer

avcodec/mjpegenc: Remove non functional huffman reallocation and error handling

If this is wanted iam not against it but it must be designed to work with all 
cases
like slice threads, and a single growing buffer does not work very well with 
slices.

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=e10bd12c250afb89046c4b0ee3f30d6d23eb8127
---

 libavcodec/mjpegenc.c| 68 +++-
 libavcodec/mjpegenc.h|  2 --
 libavcodec/mjpegenc_common.c |  7 -
 3 files changed, 30 insertions(+), 47 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index e0f1f83..e275f01 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -42,6 +42,34 @@
 // Don't know, but let's guess 16 bits per code
 #define MJPEG_HUFFMAN_EST_BITS_PER_CODE 16
 
+static int alloc_huffman(MpegEncContext *s)
+{
+MJpegContext *m = s->mjpeg_ctx;
+size_t num_mbs, num_blocks, num_codes;
+int blocks_per_mb;
+
+// We need to init this here as the mjpeg init is called before the common 
init,
+s->mb_width  = (s->width  + 15) / 16;
+s->mb_height = (s->height + 15) / 16;
+
+switch (s->chroma_format) {
+case CHROMA_420: blocks_per_mb =  6; break;
+case CHROMA_422: blocks_per_mb =  8; break;
+case CHROMA_444: blocks_per_mb = 12; break;
+default: av_assert0(0);
+};
+
+// Make sure we have enough space to hold this frame.
+num_mbs = s->mb_width * s->mb_height;
+num_blocks = num_mbs * blocks_per_mb;
+num_codes = num_blocks * 64;
+
+m->huff_buffer = av_malloc_array(num_codes, sizeof(MJpegHuffmanCode));
+if (!m->huff_buffer)
+return AVERROR(ENOMEM);
+return 0;
+}
+
 av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
 {
 MJpegContext *m;
@@ -88,13 +116,10 @@ av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
 s->intra_chroma_ac_vlc_last_length = m->uni_chroma_ac_vlc_len;
 
 // Buffers start out empty.
-m->huff_buffer = NULL;
 m->huff_ncode = 0;
-m->huff_capacity = 0;
-m->error = 0;
-
 s->mjpeg_ctx = m;
-return 0;
+
+return alloc_huffman(s);
 }
 
 av_cold void ff_mjpeg_encode_close(MpegEncContext *s)
@@ -159,7 +184,6 @@ void ff_mjpeg_encode_picture_frame(MpegEncContext *s)
 static inline void ff_mjpeg_encode_code(MJpegContext *s, uint8_t table_id, int 
code)
 {
 MJpegHuffmanCode *c = &s->huff_buffer[s->huff_ncode++];
-av_assert0(s->huff_ncode < s->huff_capacity);
 c->table_id = table_id;
 c->code = code;
 }
@@ -206,10 +230,6 @@ static void encode_block(MpegEncContext *s, int16_t 
*block, int n)
 int component, dc, last_index, val, run;
 MJpegContext *m = s->mjpeg_ctx;
 
-if (m->error) return;
-
-av_assert0(m->huff_capacity >= m->huff_ncode + 64);
-
 /* DC coef */
 component = (n <= 3 ? 0 : (n&1) + 1);
 table_id = (n <= 3 ? 0 : 1);
@@ -247,30 +267,6 @@ static void encode_block(MpegEncContext *s, int16_t 
*block, int n)
 ff_mjpeg_encode_code(m, table_id, 0);
 }
 
-// Possibly reallocate the huffman code buffer, assuming blocks_per_mb.
-// Set s->mjpeg_ctx->error on ENOMEM.
-static void realloc_huffman(MpegEncContext *s, int blocks_per_mb)
-{
-MJpegContext *m = s->mjpeg_ctx;
-size_t num_mbs, num_blocks, num_codes;
-MJpegHuffmanCode *new_buf;
-if (m->error) return;
-// Make sure we have enough space to hold this frame.
-num_mbs = s->mb_width * s->mb_height;
-num_blocks = num_mbs * blocks_per_mb;
-av_assert0(m->huff_ncode <=
-   (s->mb_y * s->mb_width + s->mb_x) * blocks_per_mb * 64);
-num_codes = num_blocks * 64;
-
-new_buf = av_fast_realloc(m->huff_buffer, &m->huff_capacity,
-  num_codes * sizeof(MJpegHuffmanCode));
-if (!new_buf) {
-m->error = AVERROR(ENOMEM);
-} else {
-m->huff_buffer = new_buf;
-}
-}
-
 int ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64])
 {
 int i, is_chroma_420;
@@ -285,7 +281,6 @@ int ff_mjpeg_encode_mb(MpegEncContext *s, int16_t 
block[12][64])
 }
 
 if (s->chroma_format == CHROMA_444) {
-realloc_huffman(s, 12);
 encode_block(s, block[0], 0);
 encode_block(s, block[2], 2);
 encode_block(s, block[4], 4);
@@ -303,7 +298,6 @@ int ff_mjpeg_encode_mb(MpegEncContext *s, int16_t 
block[12][64])
 }
 } else {
 is_chroma_420 = (s->chroma_format == CHROMA_420);
-realloc_huffman(s, 5 + (is_chroma_420 ? 1 : 3));
 for(i=0;i<5;i++) {
 encode_block(s, block[i], i);
 }
@@ -315,8 +309,6 @@ int ff_mjpeg_encode_mb(MpegEncContext *s, int16_t 
block[12][64])
 encode_block(s, block[7], 7);
 }
 }
-if (s->mjpeg_ctx->error)
-return s->mjpeg_ctx->error;
 
 

[FFmpeg-cvslog] avcodec/mjpegenc_huffman: remove unneeded header include

2017-02-09 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Feb  9 23:03:57 2017 +0100| [b39129b68e7774c5061aa02e600218b3e91d8761] | 
committer: Michael Niedermayer

avcodec/mjpegenc_huffman: remove unneeded header include

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=b39129b68e7774c5061aa02e600218b3e91d8761
---

 libavcodec/mjpegenc_huffman.c | 1 -
 1 file changed, 1 deletion(-)

diff --git a/libavcodec/mjpegenc_huffman.c b/libavcodec/mjpegenc_huffman.c
index a5d7d53..e1d300b 100644
--- a/libavcodec/mjpegenc_huffman.c
+++ b/libavcodec/mjpegenc_huffman.c
@@ -21,7 +21,6 @@
 
 #include 
 #include 
-#include 
 #include 
 #include "libavutil/common.h"
 #include "libavutil/error.h"

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/mjpegenc: Bypass the 2 pass encoding when optimal tables are not requested

2017-02-09 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Feb  9 23:24:15 2017 +0100| [3e1507a9547ac09b6ff4372123cde09f19218f3d] | 
committer: Michael Niedermayer

avcodec/mjpegenc: Bypass the 2 pass encoding when optimal tables are not 
requested

This limits the bugs, speedloss and extra memory allocation to the case when
optimal tables are needed.
Fixes regressions with slice multi-threading

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=3e1507a9547ac09b6ff4372123cde09f19218f3d
---

 libavcodec/mjpegenc.c| 144 +++
 libavcodec/mjpegenc_common.c |  11 ++--
 libavcodec/mpegvideo_enc.c   |   5 +-
 3 files changed, 128 insertions(+), 32 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index 550338f..cc917ed 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -79,7 +79,7 @@ av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
 return AVERROR(EINVAL);
 }
 
-m = av_malloc(sizeof(MJpegContext));
+m = av_mallocz(sizeof(MJpegContext));
 if (!m)
 return AVERROR(ENOMEM);
 
@@ -117,7 +117,10 @@ av_cold int ff_mjpeg_encode_init(MpegEncContext *s)
 m->huff_ncode = 0;
 s->mjpeg_ctx = m;
 
-return alloc_huffman(s);
+if(s->huffman == HUFFMAN_TABLE_OPTIMAL)
+return alloc_huffman(s);
+
+return 0;
 }
 
 av_cold void ff_mjpeg_encode_close(MpegEncContext *s)
@@ -224,7 +227,7 @@ static void ff_mjpeg_encode_coef(MJpegContext *s, uint8_t 
table_id, int val, int
  * @param block The block.
  * @param n The block's index or number.
  */
-static void encode_block(MpegEncContext *s, int16_t *block, int n)
+static void record_block(MpegEncContext *s, int16_t *block, int n)
 {
 int i, j, table_id;
 int component, dc, last_index, val, run;
@@ -267,36 +270,127 @@ static void encode_block(MpegEncContext *s, int16_t 
*block, int n)
 ff_mjpeg_encode_code(m, table_id, 0);
 }
 
+static void encode_block(MpegEncContext *s, int16_t *block, int n)
+{
+int mant, nbits, code, i, j;
+int component, dc, run, last_index, val;
+MJpegContext *m = s->mjpeg_ctx;
+uint8_t *huff_size_ac;
+uint16_t *huff_code_ac;
+
+/* DC coef */
+component = (n <= 3 ? 0 : (n&1) + 1);
+dc = block[0]; /* overflow is impossible */
+val = dc - s->last_dc[component];
+if (n < 4) {
+ff_mjpeg_encode_dc(&s->pb, val, m->huff_size_dc_luminance, 
m->huff_code_dc_luminance);
+huff_size_ac = m->huff_size_ac_luminance;
+huff_code_ac = m->huff_code_ac_luminance;
+} else {
+ff_mjpeg_encode_dc(&s->pb, val, m->huff_size_dc_chrominance, 
m->huff_code_dc_chrominance);
+huff_size_ac = m->huff_size_ac_chrominance;
+huff_code_ac = m->huff_code_ac_chrominance;
+}
+s->last_dc[component] = dc;
+
+/* AC coefs */
+
+run = 0;
+last_index = s->block_last_index[n];
+for(i=1;i<=last_index;i++) {
+j = s->intra_scantable.permutated[i];
+val = block[j];
+if (val == 0) {
+run++;
+} else {
+while (run >= 16) {
+put_bits(&s->pb, huff_size_ac[0xf0], huff_code_ac[0xf0]);
+run -= 16;
+}
+mant = val;
+if (val < 0) {
+val = -val;
+mant--;
+}
+
+nbits= av_log2_16bit(val) + 1;
+code = (run << 4) | nbits;
+
+put_bits(&s->pb, huff_size_ac[code], huff_code_ac[code]);
+
+put_sbits(&s->pb, nbits, mant);
+run = 0;
+}
+}
+
+/* output EOB only if not already 64 values */
+if (last_index < 63 || run != 0)
+put_bits(&s->pb, huff_size_ac[0], huff_code_ac[0]);
+}
+
 void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64])
 {
 int i;
-if (s->chroma_format == CHROMA_444) {
-encode_block(s, block[0], 0);
-encode_block(s, block[2], 2);
-encode_block(s, block[4], 4);
-encode_block(s, block[8], 8);
-encode_block(s, block[5], 5);
-encode_block(s, block[9], 9);
-
-if (16*s->mb_x+8 < s->width) {
-encode_block(s, block[1], 1);
-encode_block(s, block[3], 3);
-encode_block(s, block[6], 6);
-encode_block(s, block[10], 10);
-encode_block(s, block[7], 7);
-encode_block(s, block[11], 11);
+if (s->huffman == HUFFMAN_TABLE_OPTIMAL) {
+if (s->chroma_format == CHROMA_444) {
+record_block(s, block[0], 0);
+record_block(s, block[2], 2);
+record_block(s, block[4], 4);
+record_block(s, block[8], 8);
+record_block(s, block[5], 5);
+record_block(s, block[9], 9);
+
+if (16*s->mb_x+8 < s->width) {
+record_block(s, block[1], 1);
+record_block(s, block[3], 3);
+record_block(s, block[6], 6);
+  

[FFmpeg-cvslog] avcodec/mjpegenc: Revert some differences in ff_mjpeg_encode_mb() relative to pre optimal huffman

2017-02-09 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Feb  9 23:07:11 2017 +0100| [f57665b3181d5cbed680754983d9a6fdc1bfec5f] | 
committer: Michael Niedermayer

avcodec/mjpegenc: Revert some differences in ff_mjpeg_encode_mb() relative to 
pre optimal huffman

The changes are not needed anymore and the return code was never used

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=f57665b3181d5cbed680754983d9a6fdc1bfec5f
---

 libavcodec/mjpegenc.c | 10 +++---
 libavcodec/mjpegenc.h |  2 +-
 2 files changed, 4 insertions(+), 8 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index db2bc34..550338f 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -267,10 +267,9 @@ static void encode_block(MpegEncContext *s, int16_t 
*block, int n)
 ff_mjpeg_encode_code(m, table_id, 0);
 }
 
-int ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64])
+void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64])
 {
-int i, is_chroma_420;
-
+int i;
 if (s->chroma_format == CHROMA_444) {
 encode_block(s, block[0], 0);
 encode_block(s, block[2], 2);
@@ -288,11 +287,10 @@ int ff_mjpeg_encode_mb(MpegEncContext *s, int16_t 
block[12][64])
 encode_block(s, block[11], 11);
 }
 } else {
-is_chroma_420 = (s->chroma_format == CHROMA_420);
 for(i=0;i<5;i++) {
 encode_block(s, block[i], i);
 }
-if (is_chroma_420) {
+if (s->chroma_format == CHROMA_420) {
 encode_block(s, block[5], 5);
 } else {
 encode_block(s, block[6], 6);
@@ -300,8 +298,6 @@ int ff_mjpeg_encode_mb(MpegEncContext *s, int16_t 
block[12][64])
 encode_block(s, block[7], 7);
 }
 }
-
-return 0;
 }
 
 // maximum over s->mjpeg_vsample[i]
diff --git a/libavcodec/mjpegenc.h b/libavcodec/mjpegenc.h
index 271325c..3dd1ba6 100644
--- a/libavcodec/mjpegenc.h
+++ b/libavcodec/mjpegenc.h
@@ -107,6 +107,6 @@ static inline void put_marker(PutBitContext *p, enum 
JpegMarker code)
 int  ff_mjpeg_encode_init(MpegEncContext *s);
 void ff_mjpeg_encode_picture_frame(MpegEncContext *s);
 void ff_mjpeg_encode_close(MpegEncContext *s);
-int ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]);
+void ff_mjpeg_encode_mb(MpegEncContext *s, int16_t block[12][64]);
 
 #endif /* AVCODEC_MJPEGENC_H */

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/mjpegenc: Drop i_tex misuse, set itex/header bits correctly, fix 2pass encoding

2017-02-09 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Thu 
Feb  9 22:10:43 2017 +0100| [daccbe81a2be2e1bf3ee862ae65fcd1bdec229b1] | 
committer: Michael Niedermayer

avcodec/mjpegenc: Drop i_tex misuse, set itex/header bits correctly, fix 2pass 
encoding

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=daccbe81a2be2e1bf3ee862ae65fcd1bdec229b1
---

 libavcodec/mjpegenc.c | 14 ++
 1 file changed, 2 insertions(+), 12 deletions(-)

diff --git a/libavcodec/mjpegenc.c b/libavcodec/mjpegenc.c
index e275f01..db2bc34 100644
--- a/libavcodec/mjpegenc.c
+++ b/libavcodec/mjpegenc.c
@@ -39,8 +39,6 @@
 #include "mjpeg.h"
 #include "mjpegenc.h"
 
-// Don't know, but let's guess 16 bits per code
-#define MJPEG_HUFFMAN_EST_BITS_PER_CODE 16
 
 static int alloc_huffman(MpegEncContext *s)
 {
@@ -148,6 +146,7 @@ void ff_mjpeg_encode_picture_frame(MpegEncContext *s)
 size_t total_bits = 0;
 size_t bytes_needed;
 
+s->header_bits = get_bits_diff(s);
 // Estimate the total size first
 for (i = 0; i < m->huff_ncode; i++) {
 table_id = m->huff_buffer[i].table_id;
@@ -172,6 +171,7 @@ void ff_mjpeg_encode_picture_frame(MpegEncContext *s)
 }
 
 m->huff_ncode = 0;
+s->i_tex_bits = get_bits_diff(s);
 }
 
 /**
@@ -271,15 +271,6 @@ int ff_mjpeg_encode_mb(MpegEncContext *s, int16_t 
block[12][64])
 {
 int i, is_chroma_420;
 
-// Number of bits used depends on future data.
-// So, nothing that relies on encoding many times and taking the
-// one with the fewest bits will work properly here.
-if (s->i_tex_bits != MJPEG_HUFFMAN_EST_BITS_PER_CODE *
-s->mjpeg_ctx->huff_ncode) {
-av_log(s->avctx, AV_LOG_ERROR, "Unsupported encoding method\n");
-return AVERROR(EINVAL);
-}
-
 if (s->chroma_format == CHROMA_444) {
 encode_block(s, block[0], 0);
 encode_block(s, block[2], 2);
@@ -310,7 +301,6 @@ int ff_mjpeg_encode_mb(MpegEncContext *s, int16_t 
block[12][64])
 }
 }
 
-s->i_tex_bits = MJPEG_HUFFMAN_EST_BITS_PER_CODE * s->mjpeg_ctx->huff_ncode;
 return 0;
 }
 

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.org
http://ffmpeg.org/mailman/listinfo/ffmpeg-cvslog


[FFmpeg-cvslog] avcodec/mjpegenc: Simplify by moving assert into ff_mjpeg_encode_huffman_close()

2017-02-09 Thread Michael Niedermayer
ffmpeg | branch: master | Michael Niedermayer  | Fri 
Feb 10 00:18:34 2017 +0100| [ce6e7a2db1a4fc0c0294b23e3d62a492af0d0359] | 
committer: Michael Niedermayer

avcodec/mjpegenc: Simplify by moving assert into ff_mjpeg_encode_huffman_close()

Signed-off-by: Michael Niedermayer 

> http://git.videolan.org/gitweb.cgi/ffmpeg.git/?a=commit;h=ce6e7a2db1a4fc0c0294b23e3d62a492af0d0359
---

 libavcodec/mjpegenc_common.c  | 28 
 libavcodec/mjpegenc_huffman.c | 12 
 libavcodec/mjpegenc_huffman.h |  6 +++---
 3 files changed, 19 insertions(+), 27 deletions(-)

diff --git a/libavcodec/mjpegenc_common.c b/libavcodec/mjpegenc_common.c
index 722ad5e..70b036d 100644
--- a/libavcodec/mjpegenc_common.c
+++ b/libavcodec/mjpegenc_common.c
@@ -444,22 +444,18 @@ static void ff_mjpeg_build_optimal_huffman(MJpegContext 
*m)
 ff_mjpeg_encode_huffman_increment(ctx[table_id], code);
 }
 
-ret = ff_mjpeg_encode_huffman_close(&dc_luminance_ctx,
-m->bits_dc_luminance,
-m->val_dc_luminance, 12);
-av_assert0(!ret);
-ret = ff_mjpeg_encode_huffman_close(&dc_chrominance_ctx,
-m->bits_dc_chrominance,
-m->val_dc_chrominance, 12);
-av_assert0(!ret);
-ret = ff_mjpeg_encode_huffman_close(&ac_luminance_ctx,
-m->bits_ac_luminance,
-m->val_ac_luminance, 256);
-av_assert0(!ret);
-ret = ff_mjpeg_encode_huffman_close(&ac_chrominance_ctx,
-m->bits_ac_chrominance,
-m->val_ac_chrominance, 256);
-av_assert0(!ret);
+ff_mjpeg_encode_huffman_close(&dc_luminance_ctx,
+  m->bits_dc_luminance,
+  m->val_dc_luminance, 12);
+ff_mjpeg_encode_huffman_close(&dc_chrominance_ctx,
+  m->bits_dc_chrominance,
+  m->val_dc_chrominance, 12);
+ff_mjpeg_encode_huffman_close(&ac_luminance_ctx,
+  m->bits_ac_luminance,
+  m->val_ac_luminance, 256);
+ff_mjpeg_encode_huffman_close(&ac_chrominance_ctx,
+  m->bits_ac_chrominance,
+  m->val_ac_chrominance, 256);
 
 ff_mjpeg_build_huffman_codes(m->huff_size_dc_luminance,
  m->huff_code_dc_luminance,
diff --git a/libavcodec/mjpegenc_huffman.c b/libavcodec/mjpegenc_huffman.c
index e1d300b..ebf1311 100644
--- a/libavcodec/mjpegenc_huffman.c
+++ b/libavcodec/mjpegenc_huffman.c
@@ -22,6 +22,7 @@
 #include 
 #include 
 #include 
+#include "libavutil/avassert.h"
 #include "libavutil/common.h"
 #include "libavutil/error.h"
 #include "libavutil/qsort.h"
@@ -154,10 +155,9 @@ void ff_mjpeg_encode_huffman_init(MJpegEncHuffmanContext 
*s)
  * @param bits  output array where the ith character represents how many 
input values have i length encoding
  * @param val   output array of input values sorted by their encoded length
  * @param max_nval  maximum number of distinct input values
- * @return int  Return code, 0 if succeeded.
  */
-int ff_mjpeg_encode_huffman_close(MJpegEncHuffmanContext *s, uint8_t bits[17],
-  uint8_t val[], int max_nval)
+void ff_mjpeg_encode_huffman_close(MJpegEncHuffmanContext *s, uint8_t bits[17],
+   uint8_t val[], int max_nval)
 {
 int i, j;
 int nval = 0;
@@ -167,9 +167,7 @@ int ff_mjpeg_encode_huffman_close(MJpegEncHuffmanContext 
*s, uint8_t bits[17],
 for (i = 0; i < 256; i++) {
 if (s->val_count[i]) nval++;
 }
-if (nval > max_nval) {
-return AVERROR(EINVAL);
-}
+av_assert0 (nval <= max_nval);
 
 j = 0;
 for (i = 0; i < 256; i++) {
@@ -189,6 +187,4 @@ int ff_mjpeg_encode_huffman_close(MJpegEncHuffmanContext 
*s, uint8_t bits[17],
 val[i] = distincts[i].code;
 bits[distincts[i].length]++;
 }
-
-return 0;
 }
diff --git a/libavcodec/mjpegenc_huffman.h b/libavcodec/mjpegenc_huffman.h
index ec6251b..a4c53d0 100644
--- a/libavcodec/mjpegenc_huffman.h
+++ b/libavcodec/mjpegenc_huffman.h
@@ -38,9 +38,9 @@ static inline void 
ff_mjpeg_encode_huffman_increment(MJpegEncHuffmanContext *s,
 {
 s->val_count[val]++;
 }
-int ff_mjpeg_encode_huffman_close(MJpegEncHuffmanContext *s,
-  uint8_t bits[17], uint8_t val[],
-  int max_nval);
+void ff_mjpeg_encode_huffman_close(MJpegEncHuffmanContext *s,
+   uint8_t bits[17], uint8_t val[],
+   int max_nval);
 
 
 /**

___
ffmpeg-cvslog mailing list
ffmpeg-cvslog@ffmpeg.