[FFmpeg-cvslog] avfilter/avf_avectorscope: disable mirroring

2018-04-18 Thread Paul B Mahol
ffmpeg | branch: master | Paul B Mahol  | Wed Apr 18 18:14:35 
2018 +0200| [396c019795677659613900dd04a7708428756906] | committer: Paul B Mahol

avfilter/avf_avectorscope: disable mirroring

Signed-off-by: Paul B Mahol 

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

 libavfilter/avf_avectorscope.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/libavfilter/avf_avectorscope.c b/libavfilter/avf_avectorscope.c
index 75e0ee5e2a..af9f1da1ec 100644
--- a/libavfilter/avf_avectorscope.c
+++ b/libavfilter/avf_avectorscope.c
@@ -102,7 +102,7 @@ static const AVOption avectorscope_options[] = {
 { "cbrt",  "cube root",   0, AV_OPT_TYPE_CONST, {.i64=CBRT}, 0, 0, FLAGS, 
"scale" },
 { "log",   "logarithmic", 0, AV_OPT_TYPE_CONST, {.i64=LOG},  0, 0, FLAGS, 
"scale" },
 { "swap", "swap x axis with y axis", OFFSET(swap), AV_OPT_TYPE_BOOL, 
{.i64=1}, 0, 1, FLAGS },
-{ "mirror", "mirror axis", OFFSET(mirror), AV_OPT_TYPE_INT, {.i64=2}, 0, 
3, FLAGS, "mirror" },
+{ "mirror", "mirror axis", OFFSET(mirror), AV_OPT_TYPE_INT, {.i64=0}, 0, 
3, FLAGS, "mirror" },
 { "none",  "no mirror", 0, AV_OPT_TYPE_CONST, {.i64=0}, 0, 0, FLAGS, 
"mirror" },
 { "x",  "mirror x", 0, AV_OPT_TYPE_CONST, {.i64=1}, 0, 0, FLAGS, 
"mirror" },
 { "y",  "mirror y", 0, AV_OPT_TYPE_CONST, {.i64=2}, 0, 0, FLAGS, 
"mirror" },

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


[FFmpeg-cvslog] avdevice/decklink_commmon: enhance error messages when iterator creation fails

2018-04-18 Thread Marton Balint
ffmpeg | branch: master | Marton Balint  | Sun Apr 15 00:06:59 
2018 +0200| [768c0774d82c8dc8eb9c14684b619b0d3b4e2f05] | committer: Marton 
Balint

avdevice/decklink_commmon: enhance error messages when iterator creation fails

Show a more useful error message which specifies the required driver version
for the build, and use the correct context in the error message for WIN32.

Signed-off-by: Marton Balint 

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

 libavdevice/decklink_common.cpp | 28 ++--
 1 file changed, 14 insertions(+), 14 deletions(-)

diff --git a/libavdevice/decklink_common.cpp b/libavdevice/decklink_common.cpp
index b889033cf8..d8cced7c74 100644
--- a/libavdevice/decklink_common.cpp
+++ b/libavdevice/decklink_common.cpp
@@ -53,25 +53,29 @@ extern "C" {
 
 #include "decklink_common.h"
 
-#ifdef _WIN32
-IDeckLinkIterator *CreateDeckLinkIteratorInstance(void)
+static IDeckLinkIterator *decklink_create_iterator(AVFormatContext *avctx)
 {
 IDeckLinkIterator *iter;
 
+#ifdef _WIN32
 if (CoInitialize(NULL) < 0) {
-av_log(NULL, AV_LOG_ERROR, "COM initialization failed.\n");
+av_log(avctx, AV_LOG_ERROR, "COM initialization failed.\n");
 return NULL;
 }
 
 if (CoCreateInstance(CLSID_CDeckLinkIterator, NULL, CLSCTX_ALL,
  IID_IDeckLinkIterator, (void**) ) != S_OK) {
-av_log(NULL, AV_LOG_ERROR, "DeckLink drivers not installed.\n");
-return NULL;
+iter = NULL;
 }
+#else
+iter = CreateDeckLinkIteratorInstance();
+#endif
+if (!iter)
+av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator. "
+"Make sure you have DeckLink drivers " 
BLACKMAGIC_DECKLINK_API_VERSION_STRING " or newer installed.\n");
 
 return iter;
 }
-#endif
 
 #ifdef _WIN32
 static char *dup_wchar_to_utf8(wchar_t *w)
@@ -285,13 +289,11 @@ int ff_decklink_list_devices(AVFormatContext *avctx,
  int show_inputs, int show_outputs)
 {
 IDeckLink *dl = NULL;
-IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance();
+IDeckLinkIterator *iter = decklink_create_iterator(avctx);
 int ret = 0;
 
-if (!iter) {
-av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n");
+if (!iter)
 return AVERROR(EIO);
-}
 
 while (ret == 0 && iter->Next() == S_OK) {
 IDeckLinkOutput *output_config;
@@ -442,11 +444,9 @@ int ff_decklink_init_device(AVFormatContext *avctx, const 
char* name)
 struct decklink_cctx *cctx = (struct decklink_cctx *)avctx->priv_data;
 struct decklink_ctx *ctx = (struct decklink_ctx *)cctx->ctx;
 IDeckLink *dl = NULL;
-IDeckLinkIterator *iter = CreateDeckLinkIteratorInstance();
-if (!iter) {
-av_log(avctx, AV_LOG_ERROR, "Could not create DeckLink iterator\n");
+IDeckLinkIterator *iter = decklink_create_iterator(avctx);
+if (!iter)
 return AVERROR_EXTERNAL;
-}
 
 while (iter->Next() == S_OK) {
 const char *displayName;

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


[FFmpeg-cvslog] lavc/dxva2_internal: Cast the dxva2 and d3d11 decoders and cfgs to (void *).

2018-04-18 Thread Carl Eugen Hoyos
ffmpeg | branch: master | Carl Eugen Hoyos  | Sun Apr 15 
23:57:24 2018 +0200| [30270561608a2a73c0dd9e73e346addff58f0f35] | committer: 
Carl Eugen Hoyos

lavc/dxva2_internal: Cast the dxva2 and d3d11 decoders and cfgs to (void *).

Silences several warnings:
libavcodec/dxva2_internal.h:107:98: warning: pointer type mismatch in 
conditional expression
libavcodec/dxva2_internal.h:109:94: warning: pointer type mismatch in 
conditional expression

Reported-by: Reino Wijnsma

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

 libavcodec/dxva2_internal.h | 4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/libavcodec/dxva2_internal.h b/libavcodec/dxva2_internal.h
index 8bb3344090..b822af59cd 100644
--- a/libavcodec/dxva2_internal.h
+++ b/libavcodec/dxva2_internal.h
@@ -104,9 +104,9 @@ typedef struct FFDXVASharedContext {
 #if CONFIG_D3D11VA && CONFIG_DXVA2
 #define DXVA_CONTEXT_WORKAROUND(avctx, ctx) (ff_dxva2_is_d3d11(avctx) ? 
ctx->d3d11va.workaround : ctx->dxva2.workaround)
 #define DXVA_CONTEXT_COUNT(avctx, ctx)  (ff_dxva2_is_d3d11(avctx) ? 
ctx->d3d11va.surface_count : ctx->dxva2.surface_count)
-#define DXVA_CONTEXT_DECODER(avctx, ctx)(ff_dxva2_is_d3d11(avctx) ? 
ctx->d3d11va.decoder : ctx->dxva2.decoder)
+#define DXVA_CONTEXT_DECODER(avctx, ctx)(ff_dxva2_is_d3d11(avctx) ? 
(void *)ctx->d3d11va.decoder : (void *)ctx->dxva2.decoder)
 #define DXVA_CONTEXT_REPORT_ID(avctx, ctx)  (*(ff_dxva2_is_d3d11(avctx) ? 
>d3d11va.report_id : >dxva2.report_id))
-#define DXVA_CONTEXT_CFG(avctx, ctx)(ff_dxva2_is_d3d11(avctx) ? 
ctx->d3d11va.cfg : ctx->dxva2.cfg)
+#define DXVA_CONTEXT_CFG(avctx, ctx)(ff_dxva2_is_d3d11(avctx) ? 
(void *)ctx->d3d11va.cfg : (void *)ctx->dxva2.cfg)
 #define DXVA_CONTEXT_CFG_BITSTREAM(avctx, ctx)  (ff_dxva2_is_d3d11(avctx) ? 
ctx->d3d11va.cfg->ConfigBitstreamRaw : ctx->dxva2.cfg->ConfigBitstreamRaw)
 #define DXVA_CONTEXT_CFG_INTRARESID(avctx, ctx) (ff_dxva2_is_d3d11(avctx) ? 
ctx->d3d11va.cfg->ConfigIntraResidUnsigned : 
ctx->dxva2.cfg->ConfigIntraResidUnsigned)
 #define DXVA_CONTEXT_CFG_RESIDACCEL(avctx, ctx) (ff_dxva2_is_d3d11(avctx) ? 
ctx->d3d11va.cfg->ConfigResidDiffAccelerator : 
ctx->dxva2.cfg->ConfigResidDiffAccelerator)

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


[FFmpeg-cvslog] ffplay: Fix realloc_texture when input texture is NULL.

2018-04-18 Thread Matt Oliver
ffmpeg | branch: master | Matt Oliver  | Tue Apr 10 
23:01:18 2018 +1000| [6be690685a8876a61f87b2b8bf30547e09030a96] | committer: 
Matt Oliver

ffplay: Fix realloc_texture when input texture is NULL.

SDL_QueryTexture and SDL_DestroyTexture require that the input texture
pointer be non-null. Debug builds of SDL will correctly check for this
and break program execution. This patch fixes this by checking the
status of the texture pointer.

Signed-off-by: Matt Oliver 

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

 fftools/ffplay.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/fftools/ffplay.c b/fftools/ffplay.c
index bc9ddb8885..dcca9c26d8 100644
--- a/fftools/ffplay.c
+++ b/fftools/ffplay.c
@@ -834,10 +834,11 @@ static int realloc_texture(SDL_Texture **texture, Uint32 
new_format, int new_wid
 {
 Uint32 format;
 int access, w, h;
-if (SDL_QueryTexture(*texture, , , , ) < 0 || new_width 
!= w || new_height != h || new_format != format) {
+if (!*texture || SDL_QueryTexture(*texture, , , , ) < 0 
|| new_width != w || new_height != h || new_format != format) {
 void *pixels;
 int pitch;
-SDL_DestroyTexture(*texture);
+if (*texture)
+SDL_DestroyTexture(*texture);
 if (!(*texture = SDL_CreateTexture(renderer, new_format, 
SDL_TEXTUREACCESS_STREAMING, new_width, new_height)))
 return -1;
 if (SDL_SetTextureBlendMode(*texture, blendmode) < 0)

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


[FFmpeg-cvslog] avdevice/iec61883: return reference counted packets

2018-04-18 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed Apr 18 15:19:40 
2018 -0300| [b8629654c6460a28c507f816a977914e3a6f2520] | committer: James Almer

avdevice/iec61883: return reference counted packets

Fixes part of ticket #7146, dealing with leaks of packet data since
commit 87c88122703f2befcf96383d05bdf14373c22df9.

Signed-off-by: James Almer 

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

 libavdevice/iec61883.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index 7d4d37847c..b09929eb56 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -118,7 +118,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 goto exit;
 }
 
-packet->buf = av_malloc(length);
+packet->buf = av_malloc(length + AV_INPUT_BUFFER_PADDING_SIZE);
 if (!packet->buf) {
 av_free(packet);
 ret = -1;
@@ -127,6 +127,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 packet->len = length;
 
 memcpy(packet->buf, data, length);
+memset(packet->buf + length, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 if (dv->queue_first) {
 dv->queue_last->next = packet;
@@ -200,13 +201,21 @@ static int iec61883_parse_queue_dv(struct iec61883_data 
*dv, AVPacket *pkt)
 size = avpriv_dv_produce_packet(dv->dv_demux, pkt,
 packet->buf, packet->len, -1);
 dv->queue_first = packet->next;
+if (size < 0)
+av_free(packet->buf);
 av_free(packet);
 dv->packets--;
 
-if (size > 0)
-return size;
+if (size < 0)
+return -1;
 
-return -1;
+if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
+av_freep(>data);
+av_packet_unref(pkt);
+return -1;
+}
+
+return size;
 }
 
 static int iec61883_parse_queue_hdv(struct iec61883_data *dv, AVPacket *pkt)

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


[FFmpeg-cvslog] avdevice/iec61883: free the private context at the end

2018-04-18 Thread James Almer
ffmpeg | branch: master | James Almer  | Wed Apr 18 15:32:10 
2018 -0300| [5079e96bcc7aaa9cae82a58397ce986e124028e4] | committer: James Almer

avdevice/iec61883: free the private context at the end

Fixes part of ticket #7146.

Signed-off-by: James Almer 

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

 libavdevice/iec61883.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index b09929eb56..dcf7553926 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -463,6 +463,7 @@ static int iec61883_close(AVFormatContext *context)
 } else {
 iec61883_dv_fb_stop(dv->iec61883_dv);
 iec61883_dv_fb_close(dv->iec61883_dv);
+av_freep(>dv_demux);
 }
 while (dv->queue_first) {
 DVPacket *packet = dv->queue_first;

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


[FFmpeg-cvslog] avdevice/iec61883: return reference counted packets

2018-04-18 Thread James Almer
ffmpeg | branch: release/3.3 | James Almer  | Wed Apr 18 
15:19:40 2018 -0300| [bc07879bc5e4ef8ba0d2aae452c109bd5995b814] | committer: 
James Almer

avdevice/iec61883: return reference counted packets

Fixes part of ticket #7146, dealing with leaks of packet data since
commit 87c88122703f2befcf96383d05bdf14373c22df9.

Signed-off-by: James Almer 
(cherry picked from commit b8629654c6460a28c507f816a977914e3a6f2520)

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

 libavdevice/iec61883.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index 721dca38ee..aeca7616df 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -118,7 +118,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 goto exit;
 }
 
-packet->buf = av_malloc(length);
+packet->buf = av_malloc(length + AV_INPUT_BUFFER_PADDING_SIZE);
 if (!packet->buf) {
 av_free(packet);
 ret = -1;
@@ -127,6 +127,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 packet->len = length;
 
 memcpy(packet->buf, data, length);
+memset(packet->buf + length, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 if (dv->queue_first) {
 dv->queue_last->next = packet;
@@ -200,13 +201,21 @@ static int iec61883_parse_queue_dv(struct iec61883_data 
*dv, AVPacket *pkt)
 size = avpriv_dv_produce_packet(dv->dv_demux, pkt,
 packet->buf, packet->len, -1);
 dv->queue_first = packet->next;
+if (size < 0)
+av_free(packet->buf);
 av_free(packet);
 dv->packets--;
 
-if (size > 0)
-return size;
+if (size < 0)
+return -1;
 
-return -1;
+if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
+av_freep(>data);
+av_packet_unref(pkt);
+return -1;
+}
+
+return size;
 }
 
 static int iec61883_parse_queue_hdv(struct iec61883_data *dv, AVPacket *pkt)

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


[FFmpeg-cvslog] avdevice/iec61883: free packet on buffer allocation error

2018-04-18 Thread Marton Balint
ffmpeg | branch: release/3.0 | Marton Balint  | Wed Feb  8 
23:37:42 2017 +0100| [3c056989dc57c973bc63a6c85516955986c5fdcf] | committer: 
James Almer

avdevice/iec61883: free packet on buffer allocation error

Fixes Coverity CID 1396416.

Signed-off-by: Marton Balint 
(cherry picked from commit 4556dad2b7379a527134db519ab60111abefaf10)

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

 libavdevice/iec61883.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index c45ae9ae5c..721dca38ee 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -120,6 +120,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 
 packet->buf = av_malloc(length);
 if (!packet->buf) {
+av_free(packet);
 ret = -1;
 goto exit;
 }

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


[FFmpeg-cvslog] avdevice/iec61883: free packet on buffer allocation error

2018-04-18 Thread Marton Balint
ffmpeg | branch: release/3.1 | Marton Balint  | Wed Feb  8 
23:37:42 2017 +0100| [13deb0c1f6af43c4975f12478544ef718f0a7582] | committer: 
James Almer

avdevice/iec61883: free packet on buffer allocation error

Fixes Coverity CID 1396416.

Signed-off-by: Marton Balint 
(cherry picked from commit 4556dad2b7379a527134db519ab60111abefaf10)

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

 libavdevice/iec61883.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index c45ae9ae5c..721dca38ee 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -120,6 +120,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 
 packet->buf = av_malloc(length);
 if (!packet->buf) {
+av_free(packet);
 ret = -1;
 goto exit;
 }

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


[FFmpeg-cvslog] avdevice/iec61883: return reference counted packets

2018-04-18 Thread James Almer
ffmpeg | branch: release/3.0 | James Almer  | Wed Apr 18 
15:19:40 2018 -0300| [b949fd7a65405ab7226f4ce8af868e177b831ae3] | committer: 
James Almer

avdevice/iec61883: return reference counted packets

Fixes part of ticket #7146, dealing with leaks of packet data since
commit 87c88122703f2befcf96383d05bdf14373c22df9.

Signed-off-by: James Almer 
(cherry picked from commit b8629654c6460a28c507f816a977914e3a6f2520)

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

 libavdevice/iec61883.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index 721dca38ee..aeca7616df 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -118,7 +118,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 goto exit;
 }
 
-packet->buf = av_malloc(length);
+packet->buf = av_malloc(length + AV_INPUT_BUFFER_PADDING_SIZE);
 if (!packet->buf) {
 av_free(packet);
 ret = -1;
@@ -127,6 +127,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 packet->len = length;
 
 memcpy(packet->buf, data, length);
+memset(packet->buf + length, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 if (dv->queue_first) {
 dv->queue_last->next = packet;
@@ -200,13 +201,21 @@ static int iec61883_parse_queue_dv(struct iec61883_data 
*dv, AVPacket *pkt)
 size = avpriv_dv_produce_packet(dv->dv_demux, pkt,
 packet->buf, packet->len, -1);
 dv->queue_first = packet->next;
+if (size < 0)
+av_free(packet->buf);
 av_free(packet);
 dv->packets--;
 
-if (size > 0)
-return size;
+if (size < 0)
+return -1;
 
-return -1;
+if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
+av_freep(>data);
+av_packet_unref(pkt);
+return -1;
+}
+
+return size;
 }
 
 static int iec61883_parse_queue_hdv(struct iec61883_data *dv, AVPacket *pkt)

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


[FFmpeg-cvslog] avdevice/iec61883: free packet on buffer allocation error

2018-04-18 Thread Marton Balint
ffmpeg | branch: release/3.2 | Marton Balint  | Wed Feb  8 
23:37:42 2017 +0100| [1fd992af60453e1ff4d3fd3af71a6891e5bd549d] | committer: 
James Almer

avdevice/iec61883: free packet on buffer allocation error

Fixes Coverity CID 1396416.

Signed-off-by: Marton Balint 
(cherry picked from commit 4556dad2b7379a527134db519ab60111abefaf10)

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

 libavdevice/iec61883.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index c45ae9ae5c..721dca38ee 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -120,6 +120,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 
 packet->buf = av_malloc(length);
 if (!packet->buf) {
+av_free(packet);
 ret = -1;
 goto exit;
 }

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


[FFmpeg-cvslog] avdevice/iec61883: free the private context at the end

2018-04-18 Thread James Almer
ffmpeg | branch: release/3.1 | James Almer  | Wed Apr 18 
15:32:10 2018 -0300| [ac1ddc6361f3798bb168179df8f26ffb37cc3fdc] | committer: 
James Almer

avdevice/iec61883: free the private context at the end

Fixes part of ticket #7146.

Signed-off-by: James Almer 
(cherry picked from commit 5079e96bcc7aaa9cae82a58397ce986e124028e4)

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

 libavdevice/iec61883.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index aeca7616df..382b989fb1 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -463,6 +463,7 @@ static int iec61883_close(AVFormatContext *context)
 } else {
 iec61883_dv_fb_stop(dv->iec61883_dv);
 iec61883_dv_fb_close(dv->iec61883_dv);
+av_freep(>dv_demux);
 }
 while (dv->queue_first) {
 DVPacket *packet = dv->queue_first;

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


[FFmpeg-cvslog] avdevice/iec61883: free the private context at the end

2018-04-18 Thread James Almer
ffmpeg | branch: release/3.3 | James Almer  | Wed Apr 18 
15:32:10 2018 -0300| [003be3e49ede2c4e7554c5f1b080a1964e8bcd3b] | committer: 
James Almer

avdevice/iec61883: free the private context at the end

Fixes part of ticket #7146.

Signed-off-by: James Almer 
(cherry picked from commit 5079e96bcc7aaa9cae82a58397ce986e124028e4)

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

 libavdevice/iec61883.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index aeca7616df..382b989fb1 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -463,6 +463,7 @@ static int iec61883_close(AVFormatContext *context)
 } else {
 iec61883_dv_fb_stop(dv->iec61883_dv);
 iec61883_dv_fb_close(dv->iec61883_dv);
+av_freep(>dv_demux);
 }
 while (dv->queue_first) {
 DVPacket *packet = dv->queue_first;

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


[FFmpeg-cvslog] avdevice/iec61883: return reference counted packets

2018-04-18 Thread James Almer
ffmpeg | branch: release/3.4 | James Almer  | Wed Apr 18 
15:19:40 2018 -0300| [4264723b0eba4ce1febe4a0934d65a726f6a1f90] | committer: 
James Almer

avdevice/iec61883: return reference counted packets

Fixes part of ticket #7146, dealing with leaks of packet data since
commit 87c88122703f2befcf96383d05bdf14373c22df9.

Signed-off-by: James Almer 
(cherry picked from commit b8629654c6460a28c507f816a977914e3a6f2520)

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

 libavdevice/iec61883.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index 721dca38ee..aeca7616df 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -118,7 +118,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 goto exit;
 }
 
-packet->buf = av_malloc(length);
+packet->buf = av_malloc(length + AV_INPUT_BUFFER_PADDING_SIZE);
 if (!packet->buf) {
 av_free(packet);
 ret = -1;
@@ -127,6 +127,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 packet->len = length;
 
 memcpy(packet->buf, data, length);
+memset(packet->buf + length, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 if (dv->queue_first) {
 dv->queue_last->next = packet;
@@ -200,13 +201,21 @@ static int iec61883_parse_queue_dv(struct iec61883_data 
*dv, AVPacket *pkt)
 size = avpriv_dv_produce_packet(dv->dv_demux, pkt,
 packet->buf, packet->len, -1);
 dv->queue_first = packet->next;
+if (size < 0)
+av_free(packet->buf);
 av_free(packet);
 dv->packets--;
 
-if (size > 0)
-return size;
+if (size < 0)
+return -1;
 
-return -1;
+if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
+av_freep(>data);
+av_packet_unref(pkt);
+return -1;
+}
+
+return size;
 }
 
 static int iec61883_parse_queue_hdv(struct iec61883_data *dv, AVPacket *pkt)

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


[FFmpeg-cvslog] avdevice/iec61883: return reference counted packets

2018-04-18 Thread James Almer
ffmpeg | branch: release/3.1 | James Almer  | Wed Apr 18 
15:19:40 2018 -0300| [86d6fca94be70f23a8a27d3bc35d2fa7a914a4b9] | committer: 
James Almer

avdevice/iec61883: return reference counted packets

Fixes part of ticket #7146, dealing with leaks of packet data since
commit 87c88122703f2befcf96383d05bdf14373c22df9.

Signed-off-by: James Almer 
(cherry picked from commit b8629654c6460a28c507f816a977914e3a6f2520)

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

 libavdevice/iec61883.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index 721dca38ee..aeca7616df 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -118,7 +118,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 goto exit;
 }
 
-packet->buf = av_malloc(length);
+packet->buf = av_malloc(length + AV_INPUT_BUFFER_PADDING_SIZE);
 if (!packet->buf) {
 av_free(packet);
 ret = -1;
@@ -127,6 +127,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 packet->len = length;
 
 memcpy(packet->buf, data, length);
+memset(packet->buf + length, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 if (dv->queue_first) {
 dv->queue_last->next = packet;
@@ -200,13 +201,21 @@ static int iec61883_parse_queue_dv(struct iec61883_data 
*dv, AVPacket *pkt)
 size = avpriv_dv_produce_packet(dv->dv_demux, pkt,
 packet->buf, packet->len, -1);
 dv->queue_first = packet->next;
+if (size < 0)
+av_free(packet->buf);
 av_free(packet);
 dv->packets--;
 
-if (size > 0)
-return size;
+if (size < 0)
+return -1;
 
-return -1;
+if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
+av_freep(>data);
+av_packet_unref(pkt);
+return -1;
+}
+
+return size;
 }
 
 static int iec61883_parse_queue_hdv(struct iec61883_data *dv, AVPacket *pkt)

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


[FFmpeg-cvslog] avdevice/iec61883: free the private context at the end

2018-04-18 Thread James Almer
ffmpeg | branch: release/3.0 | James Almer  | Wed Apr 18 
15:32:10 2018 -0300| [29683c6ba1fce32de51c2600cdbd6733b29914d7] | committer: 
James Almer

avdevice/iec61883: free the private context at the end

Fixes part of ticket #7146.

Signed-off-by: James Almer 
(cherry picked from commit 5079e96bcc7aaa9cae82a58397ce986e124028e4)

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

 libavdevice/iec61883.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index aeca7616df..382b989fb1 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -463,6 +463,7 @@ static int iec61883_close(AVFormatContext *context)
 } else {
 iec61883_dv_fb_stop(dv->iec61883_dv);
 iec61883_dv_fb_close(dv->iec61883_dv);
+av_freep(>dv_demux);
 }
 while (dv->queue_first) {
 DVPacket *packet = dv->queue_first;

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


[FFmpeg-cvslog] avdevice/iec61883: return reference counted packets

2018-04-18 Thread James Almer
ffmpeg | branch: release/3.2 | James Almer  | Wed Apr 18 
15:19:40 2018 -0300| [53803ef71c7958d56d378b1486bfe0b077bb8958] | committer: 
James Almer

avdevice/iec61883: return reference counted packets

Fixes part of ticket #7146, dealing with leaks of packet data since
commit 87c88122703f2befcf96383d05bdf14373c22df9.

Signed-off-by: James Almer 
(cherry picked from commit b8629654c6460a28c507f816a977914e3a6f2520)

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

 libavdevice/iec61883.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index 721dca38ee..aeca7616df 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -118,7 +118,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 goto exit;
 }
 
-packet->buf = av_malloc(length);
+packet->buf = av_malloc(length + AV_INPUT_BUFFER_PADDING_SIZE);
 if (!packet->buf) {
 av_free(packet);
 ret = -1;
@@ -127,6 +127,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 packet->len = length;
 
 memcpy(packet->buf, data, length);
+memset(packet->buf + length, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 if (dv->queue_first) {
 dv->queue_last->next = packet;
@@ -200,13 +201,21 @@ static int iec61883_parse_queue_dv(struct iec61883_data 
*dv, AVPacket *pkt)
 size = avpriv_dv_produce_packet(dv->dv_demux, pkt,
 packet->buf, packet->len, -1);
 dv->queue_first = packet->next;
+if (size < 0)
+av_free(packet->buf);
 av_free(packet);
 dv->packets--;
 
-if (size > 0)
-return size;
+if (size < 0)
+return -1;
 
-return -1;
+if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
+av_freep(>data);
+av_packet_unref(pkt);
+return -1;
+}
+
+return size;
 }
 
 static int iec61883_parse_queue_hdv(struct iec61883_data *dv, AVPacket *pkt)

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


[FFmpeg-cvslog] avdevice/iec61883: free the private context at the end

2018-04-18 Thread James Almer
ffmpeg | branch: release/3.2 | James Almer  | Wed Apr 18 
15:32:10 2018 -0300| [27fc118d1c7991ec0231205a40f805d960f6e23b] | committer: 
James Almer

avdevice/iec61883: free the private context at the end

Fixes part of ticket #7146.

Signed-off-by: James Almer 
(cherry picked from commit 5079e96bcc7aaa9cae82a58397ce986e124028e4)

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

 libavdevice/iec61883.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index aeca7616df..382b989fb1 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -463,6 +463,7 @@ static int iec61883_close(AVFormatContext *context)
 } else {
 iec61883_dv_fb_stop(dv->iec61883_dv);
 iec61883_dv_fb_close(dv->iec61883_dv);
+av_freep(>dv_demux);
 }
 while (dv->queue_first) {
 DVPacket *packet = dv->queue_first;

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


[FFmpeg-cvslog] avdevice/iec61883: return reference counted packets

2018-04-18 Thread James Almer
ffmpeg | branch: release/4.0 | James Almer  | Wed Apr 18 
15:19:40 2018 -0300| [d52676da38025b78ca332e0a3d7bdb8e6fb2150d] | committer: 
James Almer

avdevice/iec61883: return reference counted packets

Fixes part of ticket #7146, dealing with leaks of packet data since
commit 87c88122703f2befcf96383d05bdf14373c22df9.

Signed-off-by: James Almer 
(cherry picked from commit b8629654c6460a28c507f816a977914e3a6f2520)

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

 libavdevice/iec61883.c | 17 +
 1 file changed, 13 insertions(+), 4 deletions(-)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index 7d4d37847c..b09929eb56 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -118,7 +118,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 goto exit;
 }
 
-packet->buf = av_malloc(length);
+packet->buf = av_malloc(length + AV_INPUT_BUFFER_PADDING_SIZE);
 if (!packet->buf) {
 av_free(packet);
 ret = -1;
@@ -127,6 +127,7 @@ static int iec61883_callback(unsigned char *data, int 
length,
 packet->len = length;
 
 memcpy(packet->buf, data, length);
+memset(packet->buf + length, 0, AV_INPUT_BUFFER_PADDING_SIZE);
 
 if (dv->queue_first) {
 dv->queue_last->next = packet;
@@ -200,13 +201,21 @@ static int iec61883_parse_queue_dv(struct iec61883_data 
*dv, AVPacket *pkt)
 size = avpriv_dv_produce_packet(dv->dv_demux, pkt,
 packet->buf, packet->len, -1);
 dv->queue_first = packet->next;
+if (size < 0)
+av_free(packet->buf);
 av_free(packet);
 dv->packets--;
 
-if (size > 0)
-return size;
+if (size < 0)
+return -1;
 
-return -1;
+if (av_packet_from_data(pkt, pkt->data, pkt->size) < 0) {
+av_freep(>data);
+av_packet_unref(pkt);
+return -1;
+}
+
+return size;
 }
 
 static int iec61883_parse_queue_hdv(struct iec61883_data *dv, AVPacket *pkt)

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


[FFmpeg-cvslog] avdevice/iec61883: free the private context at the end

2018-04-18 Thread James Almer
ffmpeg | branch: release/3.4 | James Almer  | Wed Apr 18 
15:32:10 2018 -0300| [a877ab75eb8faa2de33c9118053f44b0d4548f09] | committer: 
James Almer

avdevice/iec61883: free the private context at the end

Fixes part of ticket #7146.

Signed-off-by: James Almer 
(cherry picked from commit 5079e96bcc7aaa9cae82a58397ce986e124028e4)

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

 libavdevice/iec61883.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index aeca7616df..382b989fb1 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -463,6 +463,7 @@ static int iec61883_close(AVFormatContext *context)
 } else {
 iec61883_dv_fb_stop(dv->iec61883_dv);
 iec61883_dv_fb_close(dv->iec61883_dv);
+av_freep(>dv_demux);
 }
 while (dv->queue_first) {
 DVPacket *packet = dv->queue_first;

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


[FFmpeg-cvslog] avdevice/iec61883: free the private context at the end

2018-04-18 Thread James Almer
ffmpeg | branch: release/4.0 | James Almer  | Wed Apr 18 
15:32:10 2018 -0300| [d9e9e97e5f477f6cb42d916f41b436d269cb71c8] | committer: 
James Almer

avdevice/iec61883: free the private context at the end

Fixes part of ticket #7146.

Signed-off-by: James Almer 
(cherry picked from commit 5079e96bcc7aaa9cae82a58397ce986e124028e4)

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

 libavdevice/iec61883.c | 1 +
 1 file changed, 1 insertion(+)

diff --git a/libavdevice/iec61883.c b/libavdevice/iec61883.c
index b09929eb56..dcf7553926 100644
--- a/libavdevice/iec61883.c
+++ b/libavdevice/iec61883.c
@@ -463,6 +463,7 @@ static int iec61883_close(AVFormatContext *context)
 } else {
 iec61883_dv_fb_stop(dv->iec61883_dv);
 iec61883_dv_fb_close(dv->iec61883_dv);
+av_freep(>dv_demux);
 }
 while (dv->queue_first) {
 DVPacket *packet = dv->queue_first;

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


[FFmpeg-cvslog] lavf/tcp.c: Free allocated client URLContext in case of error.

2018-04-18 Thread Stephan Holljes
ffmpeg | branch: master | Stephan Holljes  | Fri Jan 
12 19:16:30 2018 +0100| [37175122824d2706e8d2f67fc067b189ac400cd2] | committer: 
Michael Niedermayer

lavf/tcp.c: Free allocated client URLContext in case of error.

Signed-off-by: Stephan Holljes 
Signed-off-by: Michael Niedermayer 

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

 libavformat/tcp.c | 4 +++-
 1 file changed, 3 insertions(+), 1 deletion(-)

diff --git a/libavformat/tcp.c b/libavformat/tcp.c
index 8773493df1..b0289f854f 100644
--- a/libavformat/tcp.c
+++ b/libavformat/tcp.c
@@ -208,8 +208,10 @@ static int tcp_accept(URLContext *s, URLContext **c)
 return ret;
 cc = (*c)->priv_data;
 ret = ff_accept(sc->fd, sc->listen_timeout, s);
-if (ret < 0)
+if (ret < 0) {
+ffurl_closep(c);
 return ret;
+}
 cc->fd = ret;
 return 0;
 }

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


[FFmpeg-cvslog] avformat/mov: Increase support for common encryption.

2018-04-18 Thread Jacob Trimble
ffmpeg | branch: master | Jacob Trimble  | Wed Dec  6 
16:17:54 2017 -0800| [f7221d8e670ec05471a16cc4cc1cc8e0040b5b5f] | committer: 
Michael Niedermayer

avformat/mov: Increase support for common encryption.

- Parse schm atom to get different encryption schemes.
- Allow senc atom to appear in track fragments.
- Allow 16-byte IVs.
- Allow constant IVs (specified in tenc).
- Allow only tenc to specify encryption (i.e. no senc/saiz/saio).
- Use sample descriptor to detect clear fragments.

This doesn't support:
- Different sample descriptor holding different encryption info.
  - Only first sample descriptor can be encrypted.
- Encrypted sample groups (i.e. seig).
- Non-'cenc' encryption scheme when using -decryption_key.

Signed-off-by: Jacob Trimble 
Signed-off-by: Michael Niedermayer 

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

 libavformat/isom.h |  14 ++
 libavformat/mov.c  | 394 ++---
 libavutil/encryption_info.h|   2 +-
 tests/fate/mov.mak |   8 +
 tests/ref/fate/mov-frag-encrypted  |  57 +
 tests/ref/fate/mov-tenc-only-encrypted |  57 +
 6 files changed, 450 insertions(+), 82 deletions(-)

diff --git a/libavformat/isom.h b/libavformat/isom.h
index 4da34142f0..eb942cf882 100644
--- a/libavformat/isom.h
+++ b/libavformat/isom.h
@@ -27,6 +27,7 @@
 #include 
 #include 
 
+#include "libavutil/encryption_info.h"
 #include "libavutil/mastering_display_metadata.h"
 #include "libavutil/spherical.h"
 #include "libavutil/stereo3d.h"
@@ -108,12 +109,20 @@ typedef struct MOVSbgp {
 unsigned int index;
 } MOVSbgp;
 
+typedef struct MOVEncryptionIndex {
+// Individual encrypted samples.  If there are no elements, then the 
default
+// settings will be used.
+unsigned int nb_encrypted_samples;
+AVEncryptionInfo **encrypted_samples;
+} MOVEncryptionIndex;
+
 typedef struct MOVFragmentStreamInfo {
 int id;
 int64_t sidx_pts;
 int64_t first_tfra_pts;
 int64_t tfdt_dts;
 int index_entry;
+MOVEncryptionIndex *encryption_index;
 } MOVFragmentStreamInfo;
 
 typedef struct MOVFragmentIndexItem {
@@ -215,6 +224,7 @@ typedef struct MOVStreamContext {
 
 int has_sidx;  // If there is an sidx entry for this stream.
 struct {
+// TODO: Remove once old methods are removed from mov.c
 int use_subsamples;
 uint8_t* auxiliary_info;
 uint8_t* auxiliary_info_end;
@@ -223,7 +233,11 @@ typedef struct MOVStreamContext {
 uint8_t* auxiliary_info_sizes;
 size_t auxiliary_info_sizes_count;
 int64_t auxiliary_info_index;
+
 struct AVAESCTR* aes_ctr;
+unsigned int per_sample_iv_size;  // Either 0, 8, or 16.
+AVEncryptionInfo *default_encrypted_sample;
+MOVEncryptionIndex *encryption_index;
 } cenc;
 } MOVStreamContext;
 
diff --git a/libavformat/mov.c b/libavformat/mov.c
index 1340bf3913..fc512b8d72 100644
--- a/libavformat/mov.c
+++ b/libavformat/mov.c
@@ -1330,6 +1330,7 @@ static int update_frag_index(MOVContext *c, int64_t 
offset)
 frag_stream_info[i].tfdt_dts = AV_NOPTS_VALUE;
 frag_stream_info[i].first_tfra_pts = AV_NOPTS_VALUE;
 frag_stream_info[i].index_entry = -1;
+frag_stream_info[i].encryption_index = NULL;
 }
 
 if (index < c->frag_index.nb_items)
@@ -5761,57 +5762,250 @@ static int mov_read_frma(MOVContext *c, AVIOContext 
*pb, MOVAtom atom)
 return 0;
 }
 
-static int mov_read_senc(MOVContext *c, AVIOContext *pb, MOVAtom atom)
+/**
+ * Gets the current encryption info and associated current stream context.  If
+ * we are parsing a track fragment, this will return the specific encryption
+ * info for this fragment; otherwise this will return the global encryption
+ * info for the current stream.
+ */
+static int get_current_encryption_info(MOVContext *c, MOVEncryptionIndex 
**encryption_index, MOVStreamContext **sc)
 {
+MOVFragmentStreamInfo *frag_stream_info;
 AVStream *st;
+int i;
+
+frag_stream_info = get_current_frag_stream_info(>frag_index);
+if (frag_stream_info) {
+for (i = 0; i < c->fc->nb_streams; i++) {
+if (c->fc->streams[i]->id == frag_stream_info->id) {
+  st = c->fc->streams[i];
+  break;
+}
+}
+if (i == c->fc->nb_streams)
+return 0;
+*sc = st->priv_data;
+
+if (!frag_stream_info->encryption_index) {
+frag_stream_info->encryption_index = 
av_mallocz(sizeof(*frag_stream_info->encryption_index));
+if (!frag_stream_info->encryption_index)
+return AVERROR(ENOMEM);
+}
+*encryption_index = frag_stream_info->encryption_index;
+return 1;
+} else {
+// No current track fragment, using stream level encryption